apostrophe in name

  • Thread starter Thread starter Ann
  • Start date Start date
A

Ann

I have a search form, user need to enter first name or
last name, then hit search button, then it will search in
a table.
But when user enter first name like O'henry, which
includes a apostrophe, the it gives error: missing
operator, syntax error.

How can I avoid this problem?

part of codes like:

FullName = "'" & Trim$(Me.txtLName) & ", " &
Trim$(Me.txtFName) & "'"

Thanks
 
I have a search form, user need to enter first name or
last name, then hit search button, then it will search in
a table.
But when user enter first name like O'henry, which
includes a apostrophe, the it gives error: missing
operator, syntax error.

How can I avoid this problem?

part of codes like:

FullName = "'" & Trim$(Me.txtLName) & ", " &
Trim$(Me.txtFName) & "'"

Thanks

Use doublequote characters to delimit the string rather than
singlequotes. A doublequote is represented by TWO doublequotes within
a string constant, or using its ASCII value 34:

FullName = """" & Trim(Me.txtLName & ", " & Trim(Me.txtFName) &
Chr(34)

(actually I'd use one syntax or the other, just showing both as
examples).
 
Thanks, it works
-----Original Message-----


Use doublequote characters to delimit the string rather than
singlequotes. A doublequote is represented by TWO doublequotes within
a string constant, or using its ASCII value 34:

FullName = """" & Trim(Me.txtLName & ", " & Trim (Me.txtFName) &
Chr(34)

(actually I'd use one syntax or the other, just showing both as
examples).


.
 
Back
Top