Computer Learning Zone CLZ Access Excel Word Windows

The four most common chemically active elements in the universe - hydrogen, oxygen, carbon, and nitrogen - are the four most common elements of life on Earth. We are not simply in the universe. The universe is in us.

-Neil deGrasse Tyson
 
Home   Courses   Templates   Seminars   TechHelp   Forums   Help   Contact   Join   Order   Logon  
 
Home > TechHelp > Access >
TechHelp


Back to TechHelp
 

Single report run time error Upload Images   Link  
James McMillan 
8 months ago
I watched the video on how to retrieve a single report for a customer using a VBA code. On some buttons and forms, it works great. However, it does not work on all buttons and all forms I'm getting a runtime error, see attached. Could you help me with this dilemma?
James McMillan
8 months ago

Scott Axton
8 months ago
James this is a bit to broad of a post.  Can you post, possibly with screenshots, what exactly you are having issues with?
Scott Axton
8 months ago
Sorry we posted at the same time.
Just looking at the formula is your "CustomerId=" & Customer accurate?  I'm guessing your field may be actually CustomerID
So "CustomerId=" & CustomerID

It's a bit hard to read it appears that the screen capture is cut off a bit.  Do you have spaces in your report name?
If so put them in brackets.  [ ]
In fact even if it doesn't put it in brackets.  Going back to Beginner 1, Access field names, reports, forms, etc. should only contain letters and on occasion a number.  Dashes ( - ) especially can be mistaken for subtraction.
I don't know how far along you are in your project but you will save yourself tons of headaches renaming you objects now.
James McMillan
8 months ago
The problem I have is with the DoCmd. See below. It always returns an error where it is highlighted in yellow.

DoCmd.OpenReport "TR3FlightTrainingLog", acViewPreview, , "CustomerID = " & CustomerID"
Scott Axton
8 months ago
You have an extra " after the second CustomerID

Try this:

DoCmd.OpenReport "TR3FlightTrainingLog", acViewPreview, , "CustomerID = " & CustomerID
James McMillan
8 months ago

James McMillan
8 months ago
I've attached the run time error that I'm receiving when I execute the VBA code.

DoCmd.OpenReport "TR3FlightTrainingLog", acViewPreview, , "InstructorID = " & InstructorID
James McMillan
8 months ago

Kevin Robertson
8 months ago
Do you have a valid InstructorID on your form (that is, not null)?
James McMillan
8 months ago
OK, the query was NUll. The record was blank. I'll create a record in that query and try again.
James McMillan
8 months ago
I created a record with an Instructor ID. I checked the table and the query, and the record showed in the table and the query. I ran the VBA code once again and received the same error message.
Richard Rost
5 months ago
The problem is definitely that you're missing an ID. Instead of opening the report, MsgBox that ID and I'll bet it's Null.

This thread is now closed. If you wish to comment, start a NEW discussion, below.
 


Back to TechHelp Comments
 

Start a NEW Conversation
 
Only students may post on this page. Click here for more information on how you can set up an account. If you are a student, please Log On first. Non-students may only post in the Visitor Forum.
 
Subscribe
Subscribe to TechHelp
Get notifications when this page is updated
 
 
 
 

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
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 2023 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 11/28/2023 7:30:30 AM.