AfterUpdate crashes; BeforeUpdate works

danly

Registered User.
Local time
Today, 10:47
Joined
Oct 20, 2000
Messages
10
I put a simple command in the AfterUpdate event property of a form, to update a "modified date" field:

Private Sub Form_AfterUpdate(Cancel As Integer)
Me![txtModDate] = Date
End Sub

Then when I try to add or edit a record and go to the next one, I get the message

"You can't go to the specified record--you may be at the end of a recordset."

And I can't save the record at all.

When I take that same code and put it in the BeforeUpdate event property of the form, it works fine.

What's so different about those two that they behave so differently?

Thanks in advance to anyone who has insight into this problem.

Dan Lee
 
Is it not because the record has already been saved after form update? Try moving it to the after update of a control.
 
Thanks for the tip. I put the event on the whole form rather than a control because I want the mod date to update on any data change, not just one or two fields.

And it's not that the record is already saved. When I try to exit the form, I am told that the edit or addition can not be saved at all.

Dan
 
The beforeUpdate is the place to put your code. As your code itself creates an update you are creating a never ending loop, e.g. afterUpdate update, afterupdate update etc.
 
The beforeUpdate is the place to put your code. As your code itself creates an update you are creating a never ending loop, e.g. afterUpdate update, afterupdate update etc.
 
Keith,

That totally makes sense. Thanks for that bit of wisdom.

From Florida, the current center of the political universe,

Dan
 

Users who are viewing this thread

Back
Top Bottom