Solved

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

Posted on 2009-03-29
18
716 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
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

708 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

12 Experts available now in Live!

Get 1:1 Help Now