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 
Add Customer Button
Lee Shastid 
    
45 days ago
I am trying to add a button to add customer. I know its easy to use the wizard but I am trying small things to build upon my VBA skills. I am placing a button my form "Add Customer" and going into the build event and using this code but it will not work it just keeps filtering. If I go into properties and clear out the data in the filtering column just soon as I click the button it puts it back. I am trying to use this VBA on the click event Docmd.OpenForm"CustomerF",,,"CustomerID="&CustomerID. Am I missing something?
Sami Shamma  @Reply  
             
45 days ago
Take a screenshot of the actual code that you have put in, and post it here
Kevin Robertson  @Reply  
           
45 days ago
Lee You are trying to go to an existing customer.

If what you want to do is add a new customer:
    DoCmd.OpenForm "CustomerF", , , , acFormAdd
Lee Shastid OP  @Reply  
    
45 days ago
Thank you Kevin. I had to remove one comma but it works now. Thank you to all.
Raymond Spornhauer  @Reply  
          
45 days ago
Lee


Docmd.OpenForm"CustomerF",,,"CustomerID="&CustomerID

This line does not have spaces in the correct places.  You need space between:
- Docmd.OpenForm-space-"CustomerF"
-"CustomerID="-space-&-space-CustomerID

"CustomerID=" & CustomerID is the WHERE condition, which is telling the form to OPEN the form, then go to the record WHERE CustomerID = CustomerID from the Record you are currently on.

Kevin's suggestion will take you to a new Record.

If you have a Form properties set to NOT allow adding or changing records, you will need to set these in VBA:
- Add Records set to True (only if you have this set to false)
- Fields will need to be enabled so the user can make changes (only if these are disabled)
- Allow Edits set to True (only if you have this set to false)
- Allow Deletions set to True (if you want the user to be able to delete records)

-Raymond
Lee Shastid OP  @Reply  
    
45 days ago
Raymond I should have typed it like I had it typed in event builder. I had all the spaces and I wasn't thinking about that when I posted. Kevin's way worked with just removing one comma for some reason. But it worked I now have something to learn and work with.
Raymond Spornhauer  @Reply  
          
44 days ago
Lee

Understood.  This is why we always ask to see your actual code.  If you post code with mistakes or errors, you're going to get comments on it.  Code is very specific, one letter off, or one missed space, or one mispelling can cause your code to not work.

-Raymond
Lee Shastid OP  @Reply  
    
44 days ago
My bad. You are correct. I just wasn’t thinking apparently.

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: 4/30/2026 2:30:17 AM. PLT: 1s