Link to home
Start Free TrialLog in
Avatar of damixa
damixaFlag for Denmark

asked on

update access form field when checked

I have a form with two fields

contacted - a checkbox
contactdate - a date field

i need to update the contactdate to today's date when contacted is checked

Something like this code
Private Sub Contacted_AfterUpdate()
Set contactdate = Date
End Sub

Open in new window


any help would be appreciated
Avatar of COACHMAN99
COACHMAN99

place this in click event code
if contacted then contactdate = datevalue(Now()) else contactdate =NULL
Avatar of PatHartman
I would use Date() if I only wanted the date to be stored and Now() if I wanted both date and time.

If Contacted = True then 
    ContactedDate = Date()
Else
    ContactedDate = Null
End If

Open in new window

'if contacted = true' is redundant,
if contacted then contactdate = date() else contactdate =NULL
'if contacted = true' is redundant,
True, but then inline IF - THEN statements are very difficult to read and troubleshoot downstream in massive code blocks.
ASKER CERTIFIED SOLUTION
Avatar of PatHartman
PatHartman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Very well explained, Pat.  I agree.