Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Help   Contact   Merch   Join   Order   Logon   Forums   
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Change a Report RecordSource
Robert Creedy 

16 years ago
I have a report that does exactly what I want it to do but I want run that report on different recordsets. I could make a copy of the report and make the SQL of each copy specific to a recordset, but it doesn't make much sense to have multiple copies of the same report as I'm sure to modify it later on.

So, is it possible to call the report from a form and pass it a different SQL command depending on which recordset is required? Is there a better way to do it?




Reply from Richard Rost:

Robert, unfortunately you can't change the RecordSource of a report once the report is open for printing or preview. However, there is a hack you can use to do something like this.

The trick is to open the report in DESIGN mode, make the change, and then immediately open it in PREVIEW mode. The user won't know the difference. Just make a form with two buttons on it. Each one can open the report and specify a different table for the data:

    DoCmd.OpenReport "MyReport", acViewDesign
    Reports!MyReport.RecordSource = "SELECT * FROM Table1"
    DoCmd.OpenReport "MyReport", acViewPreview

The only down side is that the user is going to see a "save changes to design of report?" when they close the report. If that's not a big deal, then this will work for you.

There are BETTER solutions, but they involve more work. For example, you could have a temporary table that is the recordsource for the report, then just run a delete query followed by an append query to fill the data into that table, then open the report.

There are a million ways to do everything in Access. Hope this helps.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 8/11/2026 4:54:48 AM. PLT: 1s