Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Assign the Sub Report at runtime 1

Status
Not open for further replies.

RSfromCO

Programmer
May 3, 2002
149
US
I have a report with a sub-report. Sometimes I want the sub report to be SubReport_A, and sometimes I want the sub report to be SubReport_B. I want to set the source of the sub-report in code. Is there a way to set the source of a sub-report in VBA? I'm not trying to set the data source, but the name of the report to use for the sub report itself.
 
Timing of your code makes this a bit difficult. I would probably put both subreports on the main report and make one or the other visible.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Assume a single subreport in the main report called subreportname. Maybe you could assign it in the detail format event like this? :

Code:
Me.subreportname.SourceObject = YourSubreportOfChoice

May also need to set link child fields if needed....

It's always darkest before dawn. So if you're going to steal your
neighbor's newspaper, that's the time to do it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top