Which event should I use

TimTDP

Registered User.
Local time
Today, 21:32
Joined
Oct 24, 2008
Messages
213
On a from I have three fields
If a user changes data in one of them I want an event to run - but only when the user navigates from the record. I don't want the event to fire when a field is updated. If this happens the event could fire three times which is not what I want.

What event should I use?

Thanks
 
I think I would use the After Update event for the form. In other words, you can edit one or more of the fields in a record and the event won't fire, but as soon as you more away from that record, then the event will fire once.

Is that what you mean?

Chris
 
Just to add to this, if the event you're looking to fire is supposed to change the value of a control, then you need the Before Update event of the Form, if this isn't the case then stopher's advice is the way to go. But then again, you will need the OldValue's value to do this because (I think) there will be no OldValue when the After Update event fires.

Also, note that most events of controls (i.e. those that manipulate records) fire before the form's Before Update event. Other control events fire after the form's related event. So what you should be thinking of doing is creating a function instead of relying on short-circuiting the control's event.

To this forward, perform a check for each of the three controls and if the Old Value is different from the new Value, run the function. E.g.:
Code:
If (txtbox1.OldValue <> txtbox1.Value) Or (txtbox2.OldValue  <> txtbox2.Value) Or (txtbox3.OldValue <> txtbox3.Value)  Then
    Call MyFunction
End If
 

Users who are viewing this thread

Back
Top Bottom