Last Modified and Modified By

R

rjw24

I have a form - frmEvents - and I want to know when the last time each record
was modified and by whom. I have created two fields LastModified and
ModifiedBy.

I have managed to write code to populate these on the AfterUpdate event on
the form. My code reads:

Private Sub Form_AfterUpdate()

[LastModified] = Now()
[ModifiedBy] = CurrentUser()

End Sub

This works fine until I try to nagivate to the next record and it says that
I cannot move to the specific record.

Can you please help?
 
A

Allen Browne

Use the BeforeUpdate event of the form.

If you use AfterUpdate, you immediately dirty the record. Then when you try
to move record, the form is dirty, so it tries to save, which triggers
Form_AfterUpdate again, so the form is dirty again, so it can't move.

You can actually break out of that cycle with Esc (to undo the change
triggered by the last Form_AfterUpdate), but the solution is to use the
correct event.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top