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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

DLookup Error 7
DLookup- multiple criteria 7
Dlookup error 13 7
dlookup 2
dlookup 2
DLookUp Help 5
Dlookup with different data types as criteria 5
Dlookup help Please !! 1

Back
Top