Odd Behavior re: Form_Load event order

W

wcprog

My company has an Access database in 2000 format. We're coming up with
some errors when running on a machine with Access 2003 installed. The
scenario in question is a form with a subform on it.

I discovered that, when stepping through the code on a machine with
Access 2000 installed, the form's Form_Load event is fired before the
subform's Form_Load event. On a machine with Access 2003 installed, it
is the opposite... the subform's Form_Load event fires before the
form's Form_Load event.

Anybody have any explanations for this (seemingly) odd behavior?

Thanks,
wcprog
 
A

Allen Browne

I don't have an explanation, so if someone else does, we would love to hear.

While I have not seen the specific issue you describe, I can confirm that
the form events do not always follow the documented order, and are not
always consistent between versions.

In general, the Open event of the subform fires before the Open event of the
subform. IME, the Load event of any form always follows its Open event
(though I did see a post from a user who claimed otherwise.) The Current
event should follow the Load event.

However, if there is code in the form's Open event that requires it to load
records, Current can be triggered. The Current event can then fire again
after the Load event. But then, Current can fire multiple times anyway in
Access 2000 and later.

When the main form's Current event fires, you are likely to see the
subform's fire (unless the field(s) named in LinkMasterFields did not change
when the main form record changed.) So, if the main form's Open event does
trigger a Current before its Load, then the subform's events are also going
to be triggered.

Whether that explains your case or not, hopefully it confirms that the
sequence of events is not as rigid as Help might suggest, and you are not
losing your sanity. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top