Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Concatenating strings in DLOOKUP and elsewhere

Status
Not open for further replies.

colezpapa

Programmer
Feb 26, 2007
86
US
I was having trouble with a DLOOKUP getting it to work correctly with a string value. I had the code...
x=DLookup("field", "table", "field = ' " & strValue & " ' ")

and I was getting an error...what worked was
"field = """ & strValue & """")

It's not clear to why this is so.
Also, I read in Allen Browne's tips that the single quote character is not the recommended approach: because it fails as soon as a name contains an apostrophe...
 
Code:
x = DLookup("field", "table", "field='" & Replace(strValue, "'", "''") & "'")

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top