Solved

How to set Source Object of a Sub Report in VBA?

Posted on 2009-03-29
18
725 Views
Last Modified: 2013-11-28
I have an Investor report, which has a coversheet sub report.  I need to set the source object of my sub report based on the Investor of the main report.  How can I set the source object using VBA?

Thank you,

Troy
0
Comment
Question by:T1080
  • 9
  • 6
  • 3
18 Comments
 
LVL 46

Expert Comment

by:tbsgadi
ID: 24012931
Hi Troy,

Use the Child /Parent Link


Good Luck!

Gary
0
 
LVL 46

Expert Comment

by:tbsgadi
ID: 24012944
Select the Subreport & go to properties Data>Link Child Fields ...


Gary
0
 

Author Comment

by:T1080
ID: 24013082
My linking is all setup, let me explain my issue better.
I have a subreport named rptCoversheet, which has a source object of Report.rptCoversheet.  I have 25 different investor coversheet reports, which leaves me the need to change the source object of my sub report depending on the investor.  

I've tried to use Me.rptCoversheet.SourceObject to change the source object, but I've been unsuccessful. I receive error 2191 which says "You can't set the source object property in print preview or after printing has started."  I could be trying to use the code in the wrong event location.  

Any suggestions on how to accomplish setting the source object?

Thank you,
Troy
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 250 total points
ID: 24013478
"You can't set the source object property in print preview or after printing has started." "

Well, the message in this case is pretty self explanatory. If the Source Object is not hard wired, you can only set it in the Open event of the report.

mx
0
 

Author Comment

by:T1080
ID: 24013765
mx
My report is grouped by Investor.  Each Investor has a different subreport (which is a coversheet).  Is there a way to get a different subreport to apprear for each Investor?  What I've done in the past is stacked multiple subreports on top of each other, but I'm at the point where I need to find a more efficient approach.  It looks like the source object may not be feasible, any Ideas on how to accomplish my objective?
Thank you,
Troy
0
 
LVL 46

Expert Comment

by:tbsgadi
ID: 24013807
Is the whole subreport different or just some graphics?
0
 

Author Comment

by:T1080
ID: 24013832
The subreports are very different.
0
 
LVL 46

Expert Comment

by:tbsgadi
ID: 24013843
I think you should build them separately & run code that opens each one in order.
0
 

Author Comment

by:T1080
ID: 24013864
What code would accomplish that?
0
 
LVL 46

Expert Comment

by:tbsgadi
ID: 24013874
Docmd.openReport Report1
Docmd.openReport Report2 etc

Add that to a command button on your form

0
 

Author Comment

by:T1080
ID: 24013910
That's not going to work as I need all the investors in 1 report.
0
 
LVL 46

Assisted Solution

by:tbsgadi
tbsgadi earned 250 total points
ID: 24014180
Then it's 25 subreports!
0
 

Author Comment

by:T1080
ID: 24014524
That's the answer I was trying to avoid, and as of now I'm at a loss for alternatives.  My brain has been going in circles over this issue.
Thanks,
Troy
0
 
LVL 75
ID: 24014533
Can you put up a screen shot of the expected layout ...

mx
0
 

Author Comment

by:T1080
ID: 24015246
My screen shot is attached in a word doc.

DB-Screen-Shot.docx
0
 
LVL 75
ID: 24015618
sorry ... I don't have Office 2007 loaded.  Can you send a .DOC file or a JPG.

thx.mx
0
 

Author Comment

by:T1080
ID: 24015761
I've converted it to 2003.

DB-Screen-Shot---2003-format.doc
0
 

Author Closing Comment

by:T1080
ID: 31564039
Thanks for your suggestions.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Send Meeting Request from Shared Mailbox 3 61
2 subforms 1 main form 1 15
query sort by digit 5 12
tab to another sub form 4 17
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

820 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