I created a table with the fields "SKU" and "ProductID".
It has one record:
SKU : AAABBB
ProductID : XP-40R-Y-2-CH
Then I ran this code
Code:
Public Sub MyTEstSKU()
Dim tmp As String
Dim thisProductId As String
thisProductId = "XP-40R-Y-2-CH"
tmp = DLookup("Sku", "tbl_products_and_sku", "Product_ID = '" & thisProductId & "'")
'should return a value
MsgBox tmp
tmp = IsNull(DLookup("Sku", "tbl_products_and_sku", "Product_ID = '" & thisProductId & "'"))
'should be false
MsgBox tmp
'changed string to something not in the table
thisProductId = "XP-40R-Y-2-CL"
tmp = IsNull(DLookup("Sku", "tbl_products_and_sku", "Product_ID = '" & thisProductId & "'"))
'should be true
MsgBox tmp
End Sub
The message boxes returned:
AAABBB
FALSE
TRUE
As far as I can tell, the syntax for DLOOKUP() is correct.
Something else is causing the error.