Subreport parent reference

  • Thread starter Thread starter MarianneZ
  • Start date Start date
M

MarianneZ

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!
 
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?
 
In a Vba procedure (Sub) for the subreport. I need this value from the
parent report to do some computations.
 
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.
 
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.
 
I'm not sure why you didn't try either of the two expressions I suggested.
Neither of mine included "Me." or "Reports.MainReport."
 
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.
 
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?
 
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 said:
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?


--
Duane Hookom
Microsoft Access MVP


MarianneZ said:
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.
 
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?

--
Duane Hookom
Microsoft Access MVP


MarianneZ said:
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 said:
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?


--
Duane Hookom
Microsoft Access MVP


MarianneZ said:
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.

:

I'm not sure why you didn't try either of the two expressions I suggested.
Neither of mine included "Me." or "Reports.MainReport."

--
Duane Hookom
Microsoft Access MVP


:

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.

:

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.
--
Duane Hookom
Microsoft Access MVP


:


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

:

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


:

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!
 
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

__________________________________


MarianneZ said:
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 said:
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?


--
Duane Hookom
Microsoft Access MVP


MarianneZ said:
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.

:

I'm not sure why you didn't try either of the two expressions I suggested.
Neither of mine included "Me." or "Reports.MainReport."

--
Duane Hookom
Microsoft Access MVP


:

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.

:

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.
--
Duane Hookom
Microsoft Access MVP


:


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

:

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


:

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!
 
Back
Top