DLookup 2007

  • Thread starter kpick4 via AccessMonster.com
  • Start date
K

kpick4 via AccessMonster.com

The following code from a subform control returns the proper value:

Private Sub PRODUCT_Change()
Text33 = DLookup(DESCRIPTION, "products", "Product=' & PRODUCT'")
End Sub

But, instead of putting it in the text box on my form it returns it as:
Runtime error 2741: The expression you entered as the query parameter
produced this error: 'SCOONER'. SCOONER is the correct return value for the
parameter ('G 50') passed into DLookup.
I have tried various other parameter values and the error message always
contains the correct return value, although the Runtime error code is
sometimes like '3075: Syntax error(missing operator) in query expression
HORIZ. CURVED FRAME'. HORIZ. CURVED FRAME is the correct return value in
that example.

Can anyone tell me why DLookup is interpreting the return value as being the
parameter value?
 
D

Douglas J. Steele

Text33 = DLookup("DESCRIPTION", "products", "Product='" & PRODUCT & "'")

Note the quotes around DESCRIPTION, and the correction of the quotes at the
end. Exagerated for clarity, that's

Text33 = DLookup("DESCRIPTION", "products", "Product=' " & PRODUCT & " ' ")
 
K

kpick4 via AccessMonster.com

That did it!!!!
Many, Many, Many thanks..

Ken

Text33 = DLookup("DESCRIPTION", "products", "Product='" & PRODUCT & "'")

Note the quotes around DESCRIPTION, and the correction of the quotes at the
end. Exagerated for clarity, that's

Text33 = DLookup("DESCRIPTION", "products", "Product=' " & PRODUCT & " ' ")
The following code from a subform control returns the proper value:
[quoted text clipped - 16 lines]
the
parameter value?
 

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

Top