?
Solved

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

Posted on 2009-03-29
18
Medium Priority
?
737 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 750 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 750 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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

770 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