DLookup Problem

  • Thread starter Thread starter tgavin
  • Start date Start date
T

tgavin

Here is my code. It is returning a type mismatch error and I can't figure out
why.

dblPriceToPurchase = DLookup("[dblPriceToPurchaseFactor]", "tblPricing",
"[intItem] = " & [intItemID] And "[intVendor] = " & Forms!frmPO![intVendor])

Thanks
Terri
 
tgavin said:
Here is my code. It is returning a type mismatch error and I can't figure
out
why.

dblPriceToPurchase = DLookup("[dblPriceToPurchaseFactor]", "tblPricing",
"[intItem] = " & [intItemID] And "[intVendor] = " &
Forms!frmPO![intVendor])


Quotes in the wrong place. Try this:

dblPriceToPurchase = _
DLookup("[dblPriceToPurchaseFactor]", "tblPricing", _
"[intItem] = " & [intItemID] & _
" And [intVendor] = " & Forms!frmPO![intVendor])

By the way, you don't actually need all those square brackets ([]) in this
case.
 
Here is my code. It is returning a type mismatch error and I can't figure out
why.

dblPriceToPurchase = DLookup("[dblPriceToPurchaseFactor]", "tblPricing",
"[intItem] = " & [intItemID] And "[intVendor] = " & Forms!frmPO![intVendor])

Thanks
Terri

regarding: = " & [intItemID] And "[intVendor] = " & Forms!etc..
"And" is not the same as & when writing code.

dblPriceToPurchase = DLookup("[dblPriceToPurchaseFactor]",
"tblPricing", "[intItem] = " & [intItemID] & "And [intVendor] = " &
Forms!frmPO![intVendor])

The above assumes both criteria fields are Number datatypes.
 
Back
Top