How to trigger the After_Update Event?

  • Thread starter Thread starter Mike Collard
  • Start date Start date
M

Mike Collard

Thanks to Mark.A.Sam I have used some code to loop through
a recordset and select each record in turn in a form that
uses the recordset as the Rowsource of a combo box.
However, there is an After_Update event attached to the
combo box which is not being triggered i.e. I want to
retrieve each record in turn on the form and have the
After_Update event associated with the combo box fired.

MS Help says :- "If you move to another record or save the
record, the form's BeforeUpdate and AfterUpdate events do
occur." I have tried this but can't get it to work.
Would it work if I could move the focus to another control
on the form and if so how do I do that?

Thanks

Mike Collard
 
Hi Mike,

You can execute the event code directly by just referencing the procedure
name:

MyCombo_AfterUpdate

or

Call MyCombo_AfterUpdate

Personally, I prefer to restrict event code execution to the event itself.
If I have code that I'd like to execute directly and from an event, I'll put
it into a separate procedure. This is purely for esthetic reasons -

So instead of:

Private Sub MyCtl_AfterUpdate()
MsgBox "The sky is blue"
End Sub

'some other code
Call MyCtl_AfterUpdate

I'll have:

Private Sub MyCtl_AfterUpdate()
BlueSky
End Sub

'some other code
Call BlueSky

Sub BlueSky()
MsgBox "The sky is blue"
End sub
 
Back
Top