Order of Events on Form/Subform (?)

C

croy

In the Help file for Access 2002, it states:

"When you open a form containing a subform, the subform and
its records are loaded before the main form. Thus, the
events for the subform and its controls (such as Open,
Current, Enter, and GotFocus) occur before the events for
the form. The Activate event doesn't occur for subforms,
however, so opening a main form triggers an Activate event
only for the main form."


How can the subform load records before the main form? How
would it "know" which records to load?
 
C

croy

In the Help file for Access 2002, it states:

"When you open a form containing a subform, the subform and
its records are loaded before the main form. Thus, the
events for the subform and its controls (such as Open,
Current, Enter, and GotFocus) occur before the events for
the form. The Activate event doesn't occur for subforms,
however, so opening a main form triggers an Activate event
only for the main form."


How can the subform load records before the main form? How
would it "know" which records to load?


Conversely, is it too late to set DefaultValue for a control
via the Current Event, and have it show (effective) on the
new record?
 
D

Dale Fye

Don't know the specifics, but you could probably figure it out by putting
some debug.print lines in the forms Open, Load, Current and subforms Open,
Load, and Current events. This would help you deciper which events fire in
what order, and what values are available. Examples might be:

debug.print "Form Open, ID=" & NZ(me.txt_ID)
debug.print "Subform Open, Form(ID) = " & me.parent.txt_ID & " SubForm(ID) =
" & me.txt_ID

If you don't like this, you can work around it be setting the subforms
SourceObject to "" in design view, then in some event (Load, OnTimer,
Current) you can set the subforms SourceObject to the name of the appropriate
subform.

HTH
Dale
 
D

Douglas J. Steele

I believe that the subform loads all of the records, and then gets filtered
on the Current event of the parent form.
 
C

croy

Don't know the specifics, but you could probably figure it out by putting
some debug.print lines in the forms Open, Load, Current and subforms Open,
Load, and Current events. This would help you deciper which events fire in
what order, and what values are available. Examples might be:

debug.print "Form Open, ID=" & NZ(me.txt_ID)
debug.print "Subform Open, Form(ID) = " & me.parent.txt_ID & " SubForm(ID) =
" & me.txt_ID

If you don't like this, you can work around it be setting the subforms
SourceObject to "" in design view, then in some event (Load, OnTimer,
Current) you can set the subforms SourceObject to the name of the appropriate
subform.


Good things to try, Dale. As long as I don't make mistakes
in the testing, that lead me in crazy circles. Like
Rumsfeld (sp) said, "It's not the known unknowns that get
us, it's the *unknown* unknowns..." or something like that.

But I do need to stop bugging others and work this stuff out
myself, wherever I can. You've given me good advice.
 
C

croy

I believe that the subform loads all of the records, and then gets filtered
on the Current event of the parent form.


Thanks Douglass. That makes perfect sense.
 

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