|
Enter Today’s Date into a
field using a Command Button
Question
I'm busy with a database for our school. On my 'Absenteeism' form I need to
insert today's date into a field. I want to click on a command button that will
automatically add today's date into the table field.
Answer
To do what you ask:
Add a command button to your form, but click on the Cancel button when the
wizard commences.
Then right click on the command button and select properties from the drop down
list.
In the properties window, click on the event tab, and place your cursor next to
'On Click', then click on the '...' button that should now appear.
Choose code builder.
The coding window will open with two lines of code similar to below:
******
Private Sub Command213_Click()
End Sub
*****
In between these two lines of code type the following.
Me!NameOfDateField = Date
Change 'NameOfDateField' to the name of the field where you wish to display
today's date.
Today’s date will now be displayed in the appropriate field.
Do you like this tip? Subscribe to my free weekly Newsletter to receive tips
weekly via email.
Click Here to subscribe.
|