Solved Dlookup with multiple NUMBER/Integer Criteria.

Local time
Today, 03:21
Joined
May 14, 2020
Messages
32
Hey all! Hopefully something simple, I think i'm just brainfarting this code, i'm trying to use a Variable to store a Dlookup value. I want to look up the "Unit Price" of the selected item from my Purchase Orders Details table.

Code:
CurrentBuyPrice = DLookup("[Unit Price]", "[tbl_PurchaseOrdersDetails]", "[POID]= '" & CurrentPOID & "' And [ProductID]= '" & CurrentPID & "'")

I'm getting type mismatch errors, I think its how i'm using my " and ' but i cant for the life of me seem to work it out at the moment. Both CurrentPOID and CurrentPID are variables storing Integers, have already been declared and are storing information correctly (used a msgbox to check). Thanks everyone!
 
You are surrounding your POID criteria and ProductID with ' ' making them text hence the type mismatch.
I assume they are numbers in which case remove the ' ' from your string concatenation.
 
if your fields are text, you use the single quote, if they are dates you use # and if they are numbers you don't use anything. So assuming your ID's are numbers

"[POID]= " & CurrentPOID & " And [ProductID]= " & CurrentPID
 
Hi. Try removing the apostrophes in your code.

Edit: Oops, too slow.
 

Users who are viewing this thread

Back
Top Bottom