Refer to a control on a subreport

  • Thread starter Thread starter Sandy H
  • Start date Start date
S

Sandy H

Hi
I have a report called rptManifest.
I have an unbound subreport called srptBlank in the report footer.
On the subreport, there is a control called lblTitle.
I am trying to change the caption of this label via code from the main form
but am having troubles referencing it.

Any help would be appreciated.
Sandy
 
How? How are you trying to change the caption?

Are you referring to the control where it "lives", i.e. on the main report,
inside the subreport? The fully qualified name might appear something like:
Reports!YourMainReport!YourSubReportControl.Report!YourControlName

Are you referring to the control only, or are you attempting to set the
control's .Caption property?

--
Regards

Jeff Boyce
Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/
 
Sandy said:
I have a report called rptManifest.
I have an unbound subreport called srptBlank in the report footer.
On the subreport, there is a control called lblTitle.
I am trying to change the caption of this label via code from the main form
but am having troubles referencing it.


I don't think there's any way to do that. A main report can
refer to some values in a subreport, but AFAIK, a main
report can not set properties of subreport controls.

The way I do this kind of thing is to set a hidden text box
on the main report to the value I want to see in the
subreport. Then use code in the label's section's Format
event to copy the value from the main report text box.

Me.lblTitle.Caption = Parent.hiddentextbox
 
Thanks, Marsh. I didn't realize that -- good thing you said something, 'cuz
I'd probably have driven myself crazy trying to make it work!

Jeff
 
Jeff said:
Thanks, Marsh. I didn't realize that -- good thing you said something, 'cuz
I'd probably have driven myself crazy trying to make it work!


Awww Jeff, now you made me go and double check why it
doesn't work and the reason is that I forgot that A2003
requires the Report property. The old shortcut syntax I
tried
Me.subreport.label.Caption
gives the Object doesn't support the property or method
error.

After I went back and checked it again, it dawned on me that
I needed to use:
Me.subreport.Report.label.Caption
and lo and behold, it worked.

So, I humbly take back my top of the head response and
suggest that Sandy try using:

Me.srptBlank.Report. lblTitle.Caption = "new caption"

which seems to work just fine in the Format event of any
section. It does not work in the main report's Open event.
 
And a second thanks... I would CERTAINLY have gone 'round the bend looking
for that!

Jeff
 
Back
Top