Solved

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

Posted on 2009-03-29
18
732 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

726 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