Form Current executing twice

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

Guest

I am enabling or disabling certain fields in
Form_Current, I happen to put a message and found
that Form_current is being called twice for
the same record.

Any ideas what I may have done wrong?
Or its ok for it to run this way?

Thank you,
-Me
 
If you are running Access 2000 or later, some of the events to fire multiple
times, so you may not be able to avoid this.

We often see people assigning values to bound controls in Form_Current.
That's a bad idea, as it dirties the record the instant it loads.

You may also find that conditional formatting affects this, especially if
Access thinks there is some cyclic dependency (e.g. subform depending on a
calculated control that recalculates when the subform loads).

If you can't avoid it, you may be able to create a form-level variable, i.e.
in the General Declarations at the top of the form's module:
Dim varID As Variant

and use that to test if you have already given the message for this record:
Private Sub Form_Current
If Not ((Me.NewRecord And IsNull(varID)) Or (Me.ID = varID)) Then
MsgBox "Looks like you moved record"
End If
varID = Me.ID
End Sub
 
Me said:
I am enabling or disabling certain fields in
Form_Current, I happen to put a message and found
that Form_current is being called twice for
the same record.

Any ideas what I may have done wrong?
Or its ok for it to run this way?


Does that happen for every record?

Do you see any adverse effects?

I have seen that on occasion for the first record as the
form is first loading, usually in a subform. Most of the
time it doesn't matter, but, depending on what you're doing
in the event procedure, it may make a difference.
 
Back
Top