Solved

Change source object of a sub report

Posted on 2013-06-11
3
548 Views
Last Modified: 2013-06-12
Hi
I have a report with a sub report. Using a form, the user can pick which subreport he wants displayed. Lets call them rptSub1, rptSub2, rptSub3.
In the code of the main report, I wanted to change the source object of the sub report, based on the option selected. For example
If Option1 = True Then
Me.rptSub.Sourceobject = "rptSub1"

Open in new window

But the Access help states
Note  You can't set or change the SourceObject property in the Open or Format events of a report.
So is there a different way to change the sub report?
Thanks
0
Comment
Question by:jdhackett
3 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 39238442
you have to open the report in the design view (using VBA.)
, change the SourceObject, close the report with option to save.

how are you opening the report? from a form?

post the code you are using to open the report.
0
 
LVL 29

Accepted Solution

by:
IrogSinta earned 500 total points
ID: 39239876
Note  You can't set or change the SourceObject property in the Open or Format events of a report.
That's interesting that it says that as I'm able to change the SourceObject of a subreport in either the OnLoad, OnOpen, and OnFormat events.  I just tried it right now.
0
 
LVL 1

Author Comment

by:jdhackett
ID: 39240601
Yes, it does work. I guess the help is not always correct!
Thanks
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Office 2016 User Guides 5 33
Unrecognized Database Format 8 93
Excel 2016 - Black cell borders 11 27
Access coding 2 13
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now