Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form events not loading in proper sequence

Status
Not open for further replies.

toddtharp

Programmer
Nov 23, 2004
8
0
0
US
Looking to see if anyone has had this problem before.

I've got a form with a tab control on it and several subforms on different tabs.

I have events coded On_Open, On_Activate and On_Current.

Recently, when opening this form, I got an error talking about a bracketing error on a field name. I've used a find and replace add-in to search all controls and code, but do not find an instance of this string which is causing the bracketing error.


The really interesting thing about this is that this error occurs before ANY of the form events. I put break points on all my load events (Open, Activate and current) and discovered first that this error happens before these events and second and most vexing, that my break points were trapping in this order: Activate -> Current -> Open

I've tried to run the built in analyzer on this form, but the database ab-ends each time.

I've googled and could not find any references to this problem and was hoping someone has seen it before.

Thanks,

Todd
 
I have found that a number of things will run when a form is loaded outside of the event procedures - it seems to do a "self-check".

Possible places to look for a bracketing error are in the recordsource (if a query) for the form, or a calculated field.
 
You need to C A E F U L L Y check the sequence of events. I believe that you will see that forms with embeded objects actually load the embeded objects before its' own objects, therefore the error / event is occuring during one of those other objects' event(s). This info is, I believe, readily available via the ubiquitous {F1} also occassionally refered to as HELP.





MichaelRed


 
Michael,

I always look to MS first, after help I usually check their kb, then I come to places like this to get help, not snark.

But thanks anyway, pal.

Payback,

I discovered the problem with the bracketing was from the default rowsource on a particular list box. I hadn't changed it, and don't know why it chose that particular moment to cause the error (which didn't mar the regular operation of the form, after the err dialog box was closed).

The form is still getting its events backwards, and I'm at a loss as to why. I put breakpts on all the forms events and it still opens with Activate-Current-Open. I did find a kb article, but I'll have to dig in my history as other work took me away.
 
Subforms load before the forms they are in.

Also the following might help from the MS Knowledgebase (search for this document) -
ACC2000: Understanding Event Order in Microsoft Access 2000

I also know that event sequences have changed in the various versions so it is helpful to know which one you are using.
 
How are ya toddtharp . . . . .

As already mentioned [blue]subforms open first[/blue], then the MainForm. You can get the type of error you described if for instance the [purple]RecordSource of a subForm is dependent on a value from the MainForm which is not yet open[/purple] . . . [blue]I don't think its the listbox, rather something referencing the listbox[/blue]. Look for this in your [purple]RecordSources!.[/purple]

Also, to explicitly view your events, do a [purple]debug.print[/purple] per event, [blue]being sure to ID the form the event resides in[/blue]. This should clear up what appears to be a reversed sequence (which I find impossible to believe).

Other than that Id start removing (cut & paste to a text file) event code in groups and see what happens.


Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top