Help with string

  • Thread starter Thread starter SAC
  • Start date Start date
S

SAC

I'm building a where clause for a customer name.

The problem occurs when a customer's name has an apostrophe in it.

Here's what I have now that doesn't work:

strWhere = strWhere & "CNME LIKE '" & Forms![frmLookup]![cboCustName] & "*'
"

Thanks.
 
Hi,
you can use double quotes intead of single:

const cQT="""" '4 double quotes

strWhere = strWhere & "CNME LIKE " & cQT & Forms![frmLookup]![cboCustName] &
"*" & cQT

also you can replace singel quote to 2 single quotes:

strWhere = strWhere & "CNME LIKE '" &
Repalce(Forms![frmLookup]![cboCustName],"'","''") & "*'"
 
Thanks!

Alex Dybenko said:
Hi,
you can use double quotes intead of single:

const cQT="""" '4 double quotes

strWhere = strWhere & "CNME LIKE " & cQT & Forms![frmLookup]![cboCustName] &
"*" & cQT

also you can replace singel quote to 2 single quotes:

strWhere = strWhere & "CNME LIKE '" &
Repalce(Forms![frmLookup]![cboCustName],"'","''") & "*'"

--
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com



SAC said:
I'm building a where clause for a customer name.

The problem occurs when a customer's name has an apostrophe in it.

Here's what I have now that doesn't work:

strWhere = strWhere & "CNME LIKE '" & Forms![frmLookup]![cboCustName] &
"*'
"

Thanks.
 
Back
Top