Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
VBA code to change report record source
MUBEEZI M 

12 years ago
Dear Joseph,

we very much want to help you. I only encourage you to feel free and share your code for us to point you to the right direction.

Just from the code you shared, there are a couple of issues;
1. The use of "Me" key word. In this context [i.e., a Me key word in the OnClick event], means you are setting the record source of the form and NOT the report you want to open to "SELECT * FROM " & PROGRAMSELECTION. If you want to set the record source of your report to be the above code, you would write Reports!YourReportName.RecordSource = "SELECT * FROM " & PROGRAMSELECTION
alternatively, you could write that code in the OnOpen event of the report as Me.RecordSource = "SELECT * FROM " & PROGRAMSELECTION but the PROGRAMSELECTION has to be clearly defined.
2. secondly, we SELECT values from a TABLE or QUERY. That means, PROGRAMSELECTION has to be a Table or Query name, which is always a string! That per se changes how your select statement will be written. That means it should be; Reports!YourReportName.RecordSource = "SELECT * FROM '" & PROGRAMSELECTION & "'"

one quick way to "debug" your application is to use the messagebox. You would for instance try to see, how is Access understanding Me.RecordSource?. You could simply do write MsgBox Me.RecordSource underneath the first line of code. If the SELECT statement is not referring to a table or query in your database, then you know there is a problem.

MICAH

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: 5/15/2026 1:02:47 AM. PLT: 0s