AfterUpdate doesn't happen?

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

Guest

I want to use the AfterUpdate event when a field (Me.NewANDI) has been
filled. The field can be completed manually or auto-filled by a button.
AfterUpdate gets triggered as it should when I manually fill it. But when
the button code fills it, the event does not occur. I suspect the problem
lies in the button code, so here it is:

Private Sub AddNewIDBttn_Click()
Dim intLastID As Integer
intLastID = DLookup("[LastID]", "LastIDTbl") 'Get the last generated ID.
Me.NewANDI = "DB" & Format(Str(intLastID + 1), "00000")
DoCmd.SetWarnings False 'Disable
warning.
DoCmd.RunSQL "UPDATE LastIDTbl SET LastID = LastID + 1 "
DoCmd.SetWarnings True 'Reset
warning.
End Sub

If anyone can tell me my error -- or point in another direction -- I would
appreciate it. Thanks.
 
The after update event only happens when you type the data into the control.
When you do so by code, you have to call the code yourself. If I am going
to call the same code from more than one place in the form's code I usually
code a separate sub and then I can call it directly as a sub. This also
helps if I want to do something slightly different if I call it from the
after update event of a text (or other entry)control or from the click event
of a button.
 
Besides what John wrote, you referred to the AfterUpdate Event of a TextBox
but you you posted the code for a CommandButton_Click Event???
 
Back
Top