Auto Date Entry

This question about Auto Date Entry explains how to add a date automatically by clicking a c´╗┐ommand 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.

I hope this tip, Auto Date Entry, is of some benefit to you.

Return to Microsoft Access Forms