By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,121 Members | 1,706 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,121 IT Pros & Developers. It's quick & easy.

I have a function in Northwind access DB which is

P: 1
Function GetListPrice(lProductID As Long) As Currency
GetListPrice = DLookupNumberWrapper("[List Price]", "Products", "[ID] = " & lProductID)
End Function
This function is in Purchase Orders Code section.

True or false field is in customer table and is the field Wholesale, which I added earlier. List price needs to be from either wholesale price field or list price field in the products table.
Apr 1 '17 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 1,430
Depending on what fires your code, you need something like
Expand|Select|Wrap|Line Numbers
  1. Function GetListPrice(lProductID As Long, Wholesale as Boolean) As Currency
  3.     If Wholsale = True Then
  4.         GetListPrice = Nz(DLookup("[WholeSale Price]", "Products", "[ID] = " & lProductID))
  5.     Else
  6.         GetListPrice = Nz(DLookup("[List Price]", "Products", "[ID] = " & lProductID))
  7.     End If
  8. End Function
I have added the Nz function in case any of your prices are Null.

I would advise against spaces in field names to avoid square brackets [].
ListPrice & WholesalePrice are perfectly easy to understand and
Nz(DLookup("ListPrice", "Products", "ID = " & lProductID))
is cleaner

Apr 1 '17 #2

Post your reply

Sign in to post your reply or Sign up for a free account.