Checkbox for Date/Time in text box

flyboy3300

New member
Local time
Today, 12:06
Joined
Dec 14, 2009
Messages
7
I am trying to set up a form in db with items that have to be completed and when completed they check a "check box" and then I would like that to show a date/time in a text box. I have tried to use macros to do this with no luck...please help
 
In the After Update event of the checkbox, put
Code:
If Me.YourCheckBoxNameHere Then
   Me.YourDateTextBoxNameHere = Now
End If
(make sure you put this in the event in the VBA window and not in the form properties dialog.

Do you want the date to be able to be unset if the checkbox is cleared?
 
Bob,

Thanks that worked, yes I would like that if the box is unchecked that date/time would go away

Ken
 
Bob,

Thanks that worked, yes I would like that if the box is unchecked that date/time would go away

Ken


So then modify the code to this:
Code:
If Me.YourCheckBoxNameHere Then
   Me.YourDateTextBoxNameHere = Now
Else
   Me.YourDateTextBoxNameHere = NULL
End If
 
Bob,

Worked perfect, thanks so much for the help. So simple when you have the right direction.

Ken
 
Bob,

Another question, when I save this it does not save the date/time, is there something else I have to do to get it to save
 
Bob,

Another question, when I save this it does not save the date/time, is there something else I have to do to get it to save

Make sure the text box is bound to a field in your table. While the form is in design view, select the control. Go to the Control Source property in the properties dialog and select the field you want the data saved to in the drop down. Save your form and that should bind it to that field. Then when it adds to that text box the data should be saved.
 
Bob,

That took care of it, thanks again. You have been a big help

Ken
 

Users who are viewing this thread

Back
Top Bottom