How to automatically update a date in a form

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

Guest

I have a field in a table called “LastUpdated†formatted to short date. The
default is set to =Now() which means all new records have the right date.. I
have a form set up for users to enter or edit records. No matter how often I
tell people to change the date if they edit something they forget. I want to
find a way to change the “LastUpdated†field to the current date if any
changes are made to any of the other fields in a record. How can I do that?
 
Just add code to the form's BEFORE UPDATE event to set the field to Now().



--
Rick B



nycCTM said:
I have a field in a table called "LastUpdated" formatted to short date. The
default is set to =Now() which means all new records have the right date.. I
have a form set up for users to enter or edit records. No matter how often I
tell people to change the date if they edit something they forget. I want to
find a way to change the "LastUpdated" field to the current date if any
changes are made to any of the other fields in a record. How can I do
that?
 
How exactly would I do that? I know where to find the form properties but
what do I need to write? I don't know code or VB or anything like that.
 
Find that event and select [Event Procedure] from the drop-down list.

Click the elipse next to the field to open the code window.

Change the code to the following....



Private Sub Form_BeforeUpdate(Cancel As Integer)
SomeControlNameHere = Date()
End Sub




Replace "SomeControlNameHere" with the name of your field.
 
Great! That works - thanks!

Rick B said:
Find that event and select [Event Procedure] from the drop-down list.

Click the elipse next to the field to open the code window.

Change the code to the following....



Private Sub Form_BeforeUpdate(Cancel As Integer)
SomeControlNameHere = Date()
End Sub




Replace "SomeControlNameHere" with the name of your field.


--
Rick B



nycCTM said:
How exactly would I do that? I know where to find the form properties but
what do I need to write? I don't know code or VB or anything like that.

Now().
 
Back
Top