Computer Learning Zone CLZ Access Excel Word Windows

Just like in bodybuilding, failure is also a necessary experience for growth in our own lives, for if we're never tested to our limits, how will we know how strong we really are? How will we ever grow?

-Arnold Schwarzenegger
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Microsoft Access 303    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 

 Chris 
      
16 years ago
Access 303.4 TI 16:25, Using Access 2007 - format Access 2000

When I execute the code, I get:

Run-time error '3075':

Syntax error(missing operator) in query expression 'CustomerID='.

When I debug, I see that CustomerID is Null just as the subroutine is called. It appears as though customerID doesn't yet exist because this is a new record, the data may not yet be present.

In Fact, one difference I saw between your working example and mine is that my OrderF opens up and has "(New Record)" in the OrderID field when the error is thrown.

I tried to pass the customerID through the WhereCondition:

Private Sub AddNewOrderBtn_Click()

   DoCmd.OpenForm "OrderF", , , "CustomerID=" & CustomerID, acFormAdd
  
   Forms!OrderF.GetCustomerAddress

End Sub

But got the same resulting error - in this case because CustomerID for a new record doesn't exist until it is entered.


The fix (Two):

1. Add a catch for when GetCustomerAddress is not called within its form:

Public Sub GetCustomerAddress(Optional Customer As Integer = 0)

   If (Customer <> 0) Then CustomerID = Customer


As well, on the CustomerF code, behind the button:

Private Sub AddNewOrderBtn_Click()

   DoCmd.OpenForm "OrderF", , , , acFormAdd
  
   Forms!OrderF.GetCustomerAddress (CustomerID)
  
2. A better fix is to add CustomerID to the newly opened form:

Private Sub AddNewOrderBtn_Click()

   DoCmd.OpenForm "OrderF", , , , acFormAdd
   Forms!OrderF!CustomerID = CustomerID
   Forms!OrderF.GetCustomerAddress

End Sub


Regards,

Chris

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

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/17/2026 3:53:24 PM. PLT: 1s