INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Changing SourceObject of a Sub Report at Runtime

Changing SourceObject of a Sub Report at Runtime

(OP)
Hi everyone,
I've been reading quite a few posts on this topic and I'm not quite clear if there is an easier solution for this than the ones I've read. So many of these post date back for at least 10 years. I hope ms access has changed since.

I have a main report with 5 different sub reports.
One of the subreports subReportPage4 has 5 different types of reports that I can use/print based on the value of few field on the main report.

If the value of the field "PRODUCT" = "Fixed Rate" then I want to change the sourceobject of subReportPage4 and use the report name 'rptFixedRate'; if the value of "PRODUCT" = "Variable Rate" I want to set the sourceObject of subReportPage4 to 'rptVariableRate', etc.

I have added code to the on Report_Open event but that code does not get executed at all.

Is there an simple solution to this or do I still have to add all the subreports to the main report and then just make the appropriate ones visible? Using this approach can make the reports load slow.

Thanks

Egstatus

RE: Changing SourceObject of a Sub Report at Runtime

Try moving the code to the detail section on paint event

RE: Changing SourceObject of a Sub Report at Runtime

(OP)
Hi MajP,
I tried on the Paint Event of the Details section of the report as suggested but it does not execute at run time either.
The code execute when I'm in design mode and use the 'Report View' option (it executes too many times though). It does not trigger if I use the 'Print Preview'. or when I execute it via:
DoCmd.OutputTo acOutputReport, ReportName

I personally thought that Report_Open event would be the ideal place to change the sourceobject of the subreport.

I will keep trying other things.

Thanks

Egstatus.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close