Access 2007 BeforeUpdate event firing unexpectedly
Posted on 2014-10-28
Access 2007, Windows 7
I have a main form with a subform.
I do some validation in the mainform BeforeUpdate event procedure.
If the validation fails, I set Cancel = True in the BeforeUpdate procedure.
In the following sequence of events:
1 - focus is on mainform bound textbox A
2 - I click on a subform textbox
3 - mainform BeforeUpdate event fires (dirty=True)
4 - validation fails, (because another required field is blank),
a msg is displayed (via a VBA msgbox statement),
Cancel is set to True in the BeforeUdpate procedure.
5 - focus returns (automatically) to mainform textbox A
6a - if I now TAB to mainform bound textbox B, focus moves quietly to B
6b - but if instead I CLICK on mainform textbox B,
the mainform BeforeUpdate event fires again, (dirty=True)
and so the same validation message is displayed again.
7 - if I click on mainform textbox B again, BeforeUpdate does NOT fire.
Why does the mainform BeforeUpdate event fire in step 6b ?