Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Subreport parent reference

22 views
Skip to first unread message

MarianneZ

unread,
Dec 18, 2008, 2:28:01 PM12/18/08
to
In a subreport Sub I am trying to pick up the value of a field in the parent
report, using Me.Parent!txtBox. I get an error saying You can't reference a
property for a control unless that control has focus. This control is in the
detail section of my main report and I'm in the Detail section of my
subreport.

So is this possible or do I have to pass the info somehow to the subreport?
If so, how? Or make its value a global?

Aaaaargh!

Duane Hookom

unread,
Dec 18, 2008, 3:44:01 PM12/18/08
to
Where are you attempting to use this value? You should be able to reference
the value of a text box from the parent report with an expression like:
=Parent.txtBox
or possibly
=Parent.Report.txtBox

You aren't printing forms are you?
--
Duane Hookom
Microsoft Access MVP

MarianneZ

unread,
Dec 18, 2008, 4:02:07 PM12/18/08
to

In a Vba procedure (Sub) for the subreport. I need this value from the
parent report to do some computations.

Duane Hookom

unread,
Dec 18, 2008, 4:36:01 PM12/18/08
to
You might want to use an invisible text box in the subreport with the control
source as I suggested. Then reference the value of the invisible text box in
your code.

MarianneZ

unread,
Dec 18, 2008, 5:35:01 PM12/18/08
to
I tried an invisible text box (actually I left it visible for testing), with
=Me.Parent!txtBox and =Me.Parent.Report.txtBox and
=Reports.MainReport.txtBox. Got the same error message for all 3 of these.
The temporarily visible text box displays #Name? or othertimes #Error.

Duane Hookom

unread,
Dec 18, 2008, 10:10:03 PM12/18/08
to
I'm not sure why you didn't try either of the two expressions I suggested.
Neither of mine included "Me." or "Reports.MainReport."

MarianneZ

unread,
Dec 19, 2008, 12:36:06 PM12/19/08
to
Well, I guess because I'm reading impaired. I did try "=Parent.txtBox"; same
error message, "#Name?" in referring text box. And when I tried
"=Parent.Report.txtBox", I got the same error plus "#Error" in the text box.

Surely there must be a way to do this.

Duane Hookom

unread,
Dec 19, 2008, 1:39:01 PM12/19/08
to
I just placed a text box in a subreport with a control source of
=[Parent].[CustomerID]
This worked exactly as I expected showing the CustomerID from the main report.

Is the name of your text box actually "txtBox"?
What is the name of the text box on the subreport?

MarianneZ

unread,
Dec 19, 2008, 3:11:00 PM12/19/08
to
Actual names: to-be-invisible text box in subreport is txtPID, text box in
Parent is txtID

So in the Control Source property for the to-be-invisible text box it says

=[Parent].[txtID]

What I see in the box is #Name? and I get the not in focus message.

Duane Hookom

unread,
Dec 19, 2008, 3:51:02 PM12/19/08
to
You don't have a field named "txtPID" do you?
Is the text box "txtID" in the same section of the main report as the
subreport?

I have not heard an error msg in a report referring to "focus". Is this
2007? Are you viewing the report in Print Preview?

boblarson

unread,
Dec 21, 2008, 2:53:00 AM12/21/08
to
If I'm not mistaken, on reports you should be referring to the FIELD and not
the control.
--
Bob Larson
Free Tutorials and Samples at http://www.btabdevelopment.com

__________________________________

0 new messages