DLookup Problem

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
 
D

Dirk Goldgar

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.
 
F

fredg

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 error 13 7
Record validation before save 1
DLookUp Multiple Criteria 4
DLookUp Help 5
Dlookup help Please !! 1
Dlookup Question 3
dlookup 2

Top