insert date automatically when clicking a check box

  • Thread starter Thread starter Sylvie
  • Start date Start date
S

Sylvie

Hello
I'm using Access 2007. How do you insert a date automatically when the user
selects a check box? On my form, there is a check box named Closed, if the
user checks the box, today's date should display automatically next to it.
How do you do that? In advance, thanks everyone for any help you can provide.
 
You'll need to put code in the AfterUpdate() event of the checkbox.
Something like this ...

If Me!chkClose = True Then
Me!txtCloseDate = Date()
Else
Me!txtCloseDate = Null
End If

This assumes if someone checked it as Closed and then unchecked it, the
edit would be undone. You might also add one of these calls to save the
changes immediately ...

Me.Dirty = True
or
DoCmd.RunCommand acCmdSaveRecord

The DoCmd call often throws an error for me, I don't know why, so I usually
just set Dirty to false. That has the same effect.
 
awesome. Thank you so much Danny. It works great.
One more question, for an option group with Yes or Not, how would you enter
the date automatically when either option is selected. Thanks
 
It's the same code without an IF condition. If the Frame Control's After Update
event, put this code ...

Me!txtCloseDate = Date()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top