Tick box

I am trying to get a "Date entered" box to automatically fill when a
tick box = true, without success so its over to the experts for some
much needed help
Thanks in advance
paul.bentley [ Do, 03 April 2008 13:37 ] [ ID #1934768 ]

Re: Tick box

So you want the field named "Date Entered" to fill in with todays date and
time, when the user checks a yes/no field named (say) IsPicked?

Use the AfterUpdate event procedure of the check box in your form. Something
like this:

Private Sub IsPicked_AfterUpdate()
If Me.IsPicked.Value Then
Me.[Date Entered] = Now()
Else
Me.[Date Entered] = Null
End If
End Sub

Use Date() instead of Now() if you only want the date (not the time as
well.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<paul.bentley [at] networkrail.co.uk> wrote in message
news:722b0a15-7160-4738-8e70-2778ad65afb9 [at] u36g2000prf.google groups.com...
>I am trying to get a "Date entered" box to automatically fill when a
> tick box = true, without success so its over to the experts for some
> much needed help
> Thanks in advance
Allen Browne [ Do, 03 April 2008 14:10 ] [ ID #1934771 ]

Re: Tick box

On 3 Apr, 12:37, paul.bent... [at] networkrail.co.uk wrote:
> I am trying to get a "Date entered" box to automatically fill when a
> tick box = true, without success so its over to the experts for some
> much needed help
> Thanks in advance

Additionally I have used the following
Private Sub Statement_Sent_AfterUpdate
If Me![Statement Sent] = True Then
Me![Statement Sent Date] = Date
Else
Me![Statement Sent Date] = Null
End If
End Sub


Which works but i have 143 records and even if i only tick on of the
yes/no boxes All of the Date entered boxes i have fill in, I want the
system to just date the one record for which the tick box refers.
paul.bentley [ Do, 03 April 2008 14:16 ] [ ID #1934772 ]

Re: Tick box

If you want to make this change for all your existing records as well, use
an Update query.

1. Create a query using this table.

2. In the Criteria under the [Statement Sent field], enter:
True

3. In the Criteria under the [Statement Sent Date], enter:
Is Null

4. Change it to an Update query (Update on Query menu.)

5. In the Update row under [Statement Sent Date], enter:
Date()

6. Run the query.
The relevant rows will now contain today's date.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<paul.bentley [at] networkrail.co.uk> wrote in message
news:2b4b7589-97e5-4cd8-8042-267e93e10fca [at] d21g2000prf.google groups.com...
> On 3 Apr, 12:37, paul.bent... [at] networkrail.co.uk wrote:
>> I am trying to get a "Date entered" box to automatically fill when a
>> tick box = true, without success so its over to the experts for some
>> much needed help
>> Thanks in advance
>
> Additionally I have used the following
> Private Sub Statement_Sent_AfterUpdate
> If Me![Statement Sent] = True Then
> Me![Statement Sent Date] = Date
> Else
> Me![Statement Sent Date] = Null
> End If
> End Sub
>
>
> Which works but i have 143 records and even if i only tick on of the
> yes/no boxes All of the Date entered boxes i have fill in, I want the
> system to just date the one record for which the tick box refers.
Allen Browne [ Do, 03 April 2008 16:00 ] [ ID #1934779 ]

Re: Tick box

paul.bentley [at] networkrail.co.uk wrote:
> On 3 Apr, 12:37, paul.bent... [at] networkrail.co.uk wrote:
>
>>I am trying to get a "Date entered" box to automatically fill when a
>>tick box = true, without success so its over to the experts for some
>>much needed help
>>Thanks in advance
>
>
> Additionally I have used the following
> Private Sub Statement_Sent_AfterUpdate
> If Me![Statement Sent] = True Then
> Me![Statement Sent Date] = Date
> Else
> Me![Statement Sent Date] = Null
> End If
> End Sub
>
>
> Which works but i have 143 records and even if i only tick on of the
> yes/no boxes All of the Date entered boxes i have fill in, I want the
> system to just date the one record for which the tick box refers.

If this is a form, this code will be pretty close. I simply add "Date"
after the fieldname/textbox

Private Sub Tick_AfterUpdate()
Dim ctl As Control
Dim frm As Form
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acCheckBox
If ctl.name <> "Tick" Then
'space then date to end of checkbox name
Me(ctlName & " Date").Value = IIf(Me.Tick, Date, Null)
End If
Case Else
End Select
Next
End Sub

Ice Cube
http://www.youtube.com/watch?v=HzeZhCt5PVA
Salad [ Do, 03 April 2008 22:44 ] [ ID #1934798 ]
Datenbanken » comp.databases.ms-access » Tick box

Vorheriges Thema: A2K app in A2K7
Nächstes Thema: HELP: Weighted Average Share Price