Apostrophe in field causes error

N

neeley

I have code that asks for two fields that match. The
field contains names with apostrophes. What syntax cloaks
the apostrophe, so VB doesn't think it is a single quote?

stLinkCriteria = "[FacilityName]=" & "'" & Me!
[FacilityName] & "'"

The error states: Syntax error (missing operator) in query
expression [FacilityName]= 'Big D's Bar & Grill"

Any help would be appreciated.
 
G

Guest

stLinkCriteria = "[FacilityName]=" & "'" & Replace(Me!
[FacilityName],"'","''") & "'"
 
N

neeley

Thank you for the help. It did the trick.
-----Original Message-----
stLinkCriteria = "[FacilityName]=" & "'" & Replace(Me!
[FacilityName],"'","''") & "'"


neeley said:
I have code that asks for two fields that match. The
field contains names with apostrophes. What syntax cloaks
the apostrophe, so VB doesn't think it is a single quote?

stLinkCriteria = "[FacilityName]=" & "'" & Me!
[FacilityName] & "'"

The error states: Syntax error (missing operator) in query
expression [FacilityName]= 'Big D's Bar & Grill"

Any help would be appreciated.
.
 

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