Nested Subreports

G

Guest

I've got a main report with three nested subreports. I need a textbox in each subreport that uses values from the subreports above it. Example:

"Main Report" contains
"Sub1" which contains
"Sub2" which contains
Sub3"

When I try to evaluate an expression in Sub2 that involves a field from Sub1 , it comes up that Sub1 is not open.

I would really appreciate any help. I don't know if this type of calculation simply can't be done, or if I'm missing smoething simple.

By the way, if I open Sub1 independently of Main Report, then the calculation works fine.
 
L

Larry Linson

More than likely, you are using the wrong notation to address the field in
the parent subform or the main report.

In a any level subform,

Me.Parent!txtYourField

will address the control "txtYourField" in the parent main form or parent
subform.

In a second-level subform, Me.Parent.Parent!txtYourField, and in a
third-level subform Me.Parent.Parent.Parent!txtYourField will address the
control "txtYourField" in the main form.

By definition, the Form displayed in a Subform control is not "Open" and you
will not find it in the Forms collection. It exists as the Form property of
the Subform Control in which it resides. So it can be a little tricky
addressing fields in other SubForms that are not Parents to the current
subform or its Parent.

For a simple example, consider a main Form, frmA, which has two level-1
Subform (neither contains the other) Controls named sbfA and sbfB. If, from
sbfA, you wanted to address TextBox txtMy in the Form embedded in sbfB, the
code would read:

Me.Parent!sbfB.Form!txtMy

Fortunately, the "Me" shorthand notation works nicely to simplify the
notation whether you are in the main Form or a Form embedded in a Subform
Control.

If you'd like to clarify the Form, Subform, Controls and the expression you
are using, perhaps someone could be more specific with help, if the
explanation above doesn't do the trick.

Larry Linson
Microsoft Access MVP

Elizabeth- MDC said:
I've got a main report with three nested subreports. I need a textbox in
each subreport that uses values from the subreports above it. Example:
"Main Report" contains
"Sub1" which contains
"Sub2" which contains
Sub3"

When I try to evaluate an expression in Sub2 that involves a field from
Sub1 , it comes up that Sub1 is not open.
I would really appreciate any help. I don't know if this type of
calculation simply can't be done, or if I'm missing smoething simple.
By the way, if I open Sub1 independently of Main Report, then the
calculation works fine.
 

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