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 
DLOOKUP
Maarten Brusselers 
   
3 years ago
I have a price per kg in my order form and want to get the correct price per kg in the form, depending on whether the customer is wholesale or retail.  Tried everything but can't get it to work.  Any advice most welcome.
Maarten Brusselers OP  @Reply  
   
3 years ago

Maarten Brusselers OP  @Reply  
   
3 years ago

Maarten Brusselers OP  @Reply  
   
3 years ago

Kevin Robertson  @Reply  
          
3 years ago
Move the code to the After Update event of the Salad Type Combo Box.
Maarten Brusselers OP  @Reply  
   
3 years ago
Thanks Kevin.
I did that but now get a runtime error 3075
Maarten Brusselers OP  @Reply  
   
3 years ago

Kevin Robertson  @Reply  
          
3 years ago
You will probably have to refer to the name of your Combo Box, not ProductsID.
PricePerKg = Nz(Dlookup("PricePerKgWholesale","ProductsT", "ProductsID=" & YourComboName),0)

Replace YourComboName with the name of your Combo Box.
Also, check spelling. Is it ProductsID or ProductID?
Maarten Brusselers OP  @Reply  
   
3 years ago
Thanks Kevin, now it works.  Why use the Nz function? In VBA can I not use a a value in field A to update field C by using an After Update Sub in field B?
Kevin Robertson  @Reply  
          
3 years ago
I added the Nz because if the price isn't found in the table for that product you will get an Invalid Use of Null Error.
Maarten Brusselers OP  @Reply  
   
3 years ago
No matter what I do, I always get the PricePerKgRetail. I have tried different ways as shown below.

If Wholesale Then
         PricePerKg = Nz(DLookup("PricePerKgWholesale", "ProductsT", "ProductsID=" & SaladCombo.Column(0)))
        Else
            PricePerKg = Nz(DLookup("PricePerKgRetail", "ProductsT", "ProductsID=" & SaladCombo.Column(0)))
        End If
_____________________________________________________________
If Wholesale Then
         PricePerKg = Nz(DLookup("PricePerKgWholesale", "ProductsT", "ProductsID=" & SaladCombo), 0)
        Else
            PricePerKg = Nz(DLookup("PricePerKgRetail", "ProductsT", "ProductsID=" & SaladCombo), 0)
        End If
______________________________________________________________
If Wholesale Then
         PricePerKg = Nz(DLookup("PricePerKgWholesale", "ProductsT", "ProductsID=" & SaladCombo), 0)
End If

If Wholesale = False Then
            PricePerKg = Nz(DLookup("PricePerKgRetail", "ProductsT", "ProductsID=" & SaladCombo), 0)
  End If
Maarten Brusselers OP  @Reply  
   
3 years ago

Maarten Brusselers OP  @Reply  
   
3 years ago
PricePerKgWholesale is 70, PricePerKgRetail is 120 (Thai Baht)
Kevin Robertson  @Reply  
          
3 years ago
Your Check Box if on the parent form, use If Parent.Wholesale Then
Maarten Brusselers OP  @Reply  
   
3 years ago
Hi Kevin, that worked.  I had not seen the Parent.field yet.  I don't think Richard used it anywhere I've seen so far.

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/2/2026 7:09:46 AM. PLT: 0s