Generate Date when any changes made in a Form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a field in a Form that requires the user to enter a date when they
make any changes to any fields in the Form. What I would like is for the
field to automatically generate the current date when any changes are made.

Thanks for any help
 
Roger Bell said:
I have a field in a Form that requires the user to enter a date when
they make any changes to any fields in the Form. What I would like
is for the field to automatically generate the current date when any
changes are made.

Thanks for any help

For this you would use the form's BeforeUpdate event. That event will
only fire when a modified record is about to be saved, so it's a good
place to put logic to set the last-modified date. Sample code for the
event procedure would look like this:

'----- start of example code -----
Private Sub Form_BeforeUpdate(Cancel As Integer)

Me.LastModified = Date

End Sub
'----- end of example code -----

In the above, you would replace "LastModified" with the name of your
date field. If you want to note both the date and time of the
modification, use

Me.LastModified = Now
 
Back
Top