Solved

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

Posted on 2009-03-29
18
719 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
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA to alter Table in MS Access .mbd (2000-2003) database 5 27
Run Time Error 3075 15 41
Sub Reports 8 21
Update fields from multiple tables via same form 2 22
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
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…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

929 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

17 Experts available now in Live!

Get 1:1 Help Now