Pwyd said:
thank you marshall. Let me ask you another question while i've got you here.
I've heard it said that the subform renders before a main form. Does this
also mean the data associated with it is also rendered first? If i have a
new record, and a piece of information in the subform is base on a piece of
information on the main form, would the subform state an error if it tried to
get that bit of data? or would it just fail to appear?
The word "render" means to draw a form, its controls and
display the values. I don't know when stuff is rendered,
but the form is painted/rendered at a lower priority than
everything else so I would expect that the order that things
are painted doesn't really matter because most everthing
else is done before that.
OTOH, I suspect that you are really asking about when the
data is loaded/calculated and, yes subform's are loaded
before the main form (unlike subreports). But, I'm fairly
sure that subforms are requeried/recalculated/repainted
after the main form is loaded (at least the Link
Master/Child properties require all that). So a subfom
control epression that references a main form value should
end up being ok. Try it and see what happens.
BUT, since VBA code executes at the higest priority, any
subform code that tries to reference a main form control
will error until after the main form is loaded.
If you are really curious, add a Debug.Print statement to
the main form and subform Open, Load and Current events.
Then you can look at the Immediate window to see the order
and how many times the events happen. You could even create
a Public function in a standard module and add it to a
control expression to see when the control is recalculated:
Public Function Debugging(mymsg As String, retval)
Debug.Print mymsg
Debugging = retval
End Function
Then a control expression like =Parent.textbox could be
temporarily modified to:
For a number type main form value:
=Parent.textbox+Debugging("subform control A", 0)
Or, for a mainform text box with a string value:
=Parent.textbox+Debugging("subform control B", "")
Play around with stuff like that when you have an issue of
when/what Access is doing whatever.