I am relatively new to Access and need some help. Can someone tell me how to create a check box in a form that automatically enters the date/time the box is checked into its corresponding table?
I assume you have a form with two controls. I'll call the checkbox control "chkBox" and the text box that will hold the date/time, "txtDate". You can set the "visible" property of txtDate to "true" while you work on the form and reset it later to "false", if you don't need the user of your application to see what is happening behind the screens. If you are trying to update a database table, then I'll assume that the "Control Source" property of txtDate contains the name of your database column.
You need to decide whether you also need to store the value of the checkbox in your database.
What should happen if the user checks the box, then unchecks it? Let's assume that you want to undo the update of the Date/Time...
Set chkBox property "After Update" to [Event Procedure] and click on the button that appears at the end of the property (it looks like it contains "...".
That should take you to the "code" form and you can then paste this code...
Private Sub chkBox_AfterUpdate()
If chkBox = True Then
txtDate = Now()
Else
docmd.RunCommand acCmdUndo
End If
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.