Dlookup Question/Problem

G

Guest

Hi,
Can anyone please see a fault with this line..
stCriteria = "ProductCode=" & Me!ProductCode
Me!QualityCode = DLookup(QualityCode, [dbo_DProduct], stCriteria)

The error im getting is "cannot find the "|" Field Reffered to in the
expression.

Thanks
 
J

John Vinson

Hi,
Can anyone please see a fault with this line..
stCriteria = "ProductCode=" & Me!ProductCode
Me!QualityCode = DLookup(QualityCode, [dbo_DProduct], stCriteria)

The error im getting is "cannot find the "|" Field Reffered to in the
expression.

Thanks

Just in addition to Tom's suggestions - if ProductCode is a Text type
field than the stCriteria must include the syntactically required
quotemark delimiters:

stCriteria = "ProductCode = '" & Me.ProductCode & "'"

Also, the first and second arguments to DLookUp must be text strings
containing the name of a field and a table/query - you're not passing
text strings, you're passing the actual value of the field! Try

DLookUp("QualityCode", "dbo_DProduct", stCriteria)

John W. Vinson[MVP]
 
G

Guest

Hi,
Thanks for the replys,
Using the code you have suggested stops the previous error but its throwing
a new one out, Data Mistmatch in Expression, im pretty sure this is due to a
field having different data type but they are all set as text...


Thanks

John Vinson said:
Hi,
Can anyone please see a fault with this line..
stCriteria = "ProductCode=" & Me!ProductCode
Me!QualityCode = DLookup(QualityCode, [dbo_DProduct], stCriteria)

The error im getting is "cannot find the "|" Field Reffered to in the
expression.

Thanks

Just in addition to Tom's suggestions - if ProductCode is a Text type
field than the stCriteria must include the syntactically required
quotemark delimiters:

stCriteria = "ProductCode = '" & Me.ProductCode & "'"

Also, the first and second arguments to DLookUp must be text strings
containing the name of a field and a table/query - you're not passing
text strings, you're passing the actual value of the field! Try

DLookUp("QualityCode", "dbo_DProduct", stCriteria)

John W. Vinson[MVP]
 

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 4
Blank Fields in Report 2
Dlookups ................! 1
Dlookup not working 2
DLookup and Nz 0
Multi Select List to a Report Dev Ashish 3
Dlookup condition result 4
Select in .OPEN 17

Top