On Mon, 2 Feb 2004 13:20:57 -0800, "Ann"
<(E-Mail Removed)> wrote:
>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).
John W. Vinson[MVP]
Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public