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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing SourceObject of Subreport

Status
Not open for further replies.

kram327

Technical User
Feb 12, 2004
10
US
Hi

I have multiple reports and I want to incorporate it in the main report. There's only one subreport which will only show specific data based on a specific account (field) it currently shows. The code below that I've created is not working since I don't know where I will place it in the report's event procedure:

If Account.Value = "Account1" then
Me!Child26.SourceObject = "report1"
ElseIf Account.Value = "Account2" then
Me!Child26.SourceObject = "report2"
ElseIf Account.Value = "Account3" then
Me!Child26.SourceObject = "report3"
Else
Me!Child26.SourceObject = "report4"
End if

I also placed the following set up in the properties of Child26 (under the Data tab):
Source Object = Blank
Link Child Fields = Date;Account
Link Master Fields = Date;Account

Hope you'll be able to help me, I've been sitting for hours trying to think of different solutions. And if you have a better solution, I will appreciate it.
Thanks in advance.
 
I think this is near impossible other than for the first instance of the subreport. You may need to create multiple subreports and make them visible or invisible.

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]
[blue]Ask me about my grandson, get a grand answer.[/blue]
 
There is no "OnCurrent" event of a report. The most likely candidate for a report event would be the On Format event of the section containing the subreport. Again, I think this is difficult. That's why I suggested using multiple subreport objects and setting them to visible/invisible as required.

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]
[blue]Ask me about my grandson, get a grand answer.[/blue]
 
Duane--i don't know what i was thinking. Too much turkey I guess.

And you're right--you can't change the source object after the report starts printing. You get an error message whether OnFormat or OnPrint.

So Kram--do what Duane suggests--make multiple subreports on top of each other. Use the section's OnFormat property to make each visible or invisible as required.

g
 
I should have also mentioned there could be other solutions depending on how the subreports differ. Is it possible to use a single subreport and make changes (possibly) dynamic while formatting the sections of the subreport?

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]
[blue]Ask me about my grandson, get a grand answer.[/blue]
 
Thanks guys, the multiple subreports on top of one another are working perfectly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top