DLookup 2007

  • Thread starter Thread starter kpick4 via AccessMonster.com
  • Start date 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?
 
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 & " ' ")
 
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?
 
Back
Top