Tracking date of last record edit

davesmith202

Employee of Access World
Local time
Today, 18:42
Joined
Jul 20, 2001
Messages
522
I have a Form with a field called LastUpdate. I want to track whenever the record was edited and put the current date/time in the LastUpdate field.

Do I just use the Forms AfterUpdate event and use now() or today()?

Thanks,

Dave
 
Last edited:
If you do

Code:
Private Sub Form_AfterUpdate()
    Me!LastUpdate = Now()
End Sub

You'll have an infinite loop of the AfterUpdate event triggering a new update. (More precisely it won't let you move from the record because the update never is completed)

I think it should be fine to have that line at the very end of the Form's BeforeUpdate event (after any validation you may have and only processed if valid).
 
Interesting point! That seems to do the job. Thank you. :)
 
You're welcome.

It's just a pity Access doesn't have Triggers or you could do that sort of stuff at a table level.

In Access it's up to you to make sure every form based on that table has that code and nobody can open the table directly and edit records there (or in a query). Otherwise you'll never be sure that date is indeed the last modified date.
 

Users who are viewing this thread

Back
Top Bottom