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 
How to check for existing product id in a subform
Andrew N 
    
14 years ago
Hi I have developed a Point of sale Invoice Form from the WorkOrder/Invoice forms found in the WorkOrder seminar. I use a barcode scanner to populate a product into the subform using the following vba code DoCmd.GoToControl "ProductID"
    DoCmd.GoToRecord , , acNewRec
    ProductID = ProductComboB
    Description = ProductComboB.Column(2)
    UnitPrice = ProductComboB.Column(3)
    Quantity = 1
    Notes = DLookup("Notes", "ProductT", "ProductID=" & ProductComboB)
    IsTaxable = DLookup("IsTaxable", "ProductT", "ProductID=" & ProductComboB)
    ProductComboB = ""
    DoCmd.GoToControl "ProductComboB"
    Me.Refresh

What I would like to achieve is when someone scans a product during a sale the vba code checks to see if there is an existing product with the same Product ID already entered in the subform. If the product ID is already entered in the subform then just enter a quantity of 1 to the quantity field already existing. Else enter in a new record in the subform if the product id is not there. Many thanks in advance Andrew.  The present VBA code fires in the after update event of the ProductComboB


Reply from Richard Rost:

Well, there are a couple of ways you could do it. One would be to DLOOKUP the values in your subform and see if it's there. If so you could modify it with a recordset or some UPDATE SQL command and then refresh the subform.

Another way you could do it would be to crawl down the lines of your subform using DoCmd.GoToRecord commands and see if that ID exists. If so, just manually add the value.

Your choice. :)

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/17/2026 5:45:47 AM. PLT: 1s