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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dlookup - single quote in criteria 1

Status
Not open for further replies.

jibberski

Programmer
Aug 24, 2005
52
US
GRRRR - frustrating error

Using access 2003:

How do you handle a Dlookup with a single quote in the criteria?

ie < O'brien > or < The smiths' >

Code:
Nz(DLookup("[TotalSales]", "SalesTeam", "[Name] = '" & StrV & "'"), 0)

Produces
Runtime error 3075: syntax error in string in query expression
'Name='TheSmiths'
 
Nz(DLookup("[TotalSales]", "SalesTeam", [tt]"[Name] = '" & [!]Replace(StrV, "'", "''")[/!] & "'"), 0)[/tt]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top