Solved

Change source object of a sub report

Posted on 2013-06-11
3
566 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 120

Expert Comment

by:Rey Obrero (Capricorn1)
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
Outlook Free & Paid Tools
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

749 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