By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,477 Members | 1,602 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,477 IT Pros & Developers. It's quick & easy.

FindFirst and Apostrophe

P: n/a
I get "error 3077 Syntax Error (missing operator) in expression" in this
expression:
Rst.FindFirst "[Section]='" & Me!NewSection & "'"
when Me!NewSection contains an apostrophe.

How can I write the FindFirst expression so it works whether or not
Me!NewSection contains an apostrophe?

Thanks!

Mark
Nov 12 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Try:
Rst.FindFirst "[Section]=""" & Me!NewSection & """"
--
Duane Hookom
MS Access MVP
"Mark" <mm*****@Earthlink.net> wrote in message
news:Im*****************@newsread2.news.atl.earthl ink.net...
I get "error 3077 Syntax Error (missing operator) in expression" in this
expression:
Rst.FindFirst "[Section]='" & Me!NewSection & "'"
when Me!NewSection contains an apostrophe.

How can I write the FindFirst expression so it works whether or not
Me!NewSection contains an apostrophe?

Thanks!

Mark

Nov 12 '05 #2

P: n/a
Mark wrote:
I get "error 3077 Syntax Error (missing operator) in expression" in
this expression:
Rst.FindFirst "[Section]='" & Me!NewSection & "'"
when Me!NewSection contains an apostrophe.

How can I write the FindFirst expression so it works whether or not
Me!NewSection contains an apostrophe?

Thanks!

Mark


Don't use the apostraphe as your text delimiter, use the double quote
character:

Rst.FindFirst "[Section]=" & Chr(32) & Me!NewSection & Chr(32)

ps. Perhaps don't cross-post either! :)
--
regards,

Bradley
Nov 12 '05 #3

P: n/a
Mark wrote:
I get "error 3077 Syntax Error (missing operator) in expression" in this
expression:
Rst.FindFirst "[Section]='" & Me!NewSection & "'"
when Me!NewSection contains an apostrophe.

How can I write the FindFirst expression so it works whether or not
Me!NewSection contains an apostrophe?


As others have said the double quote thing, that can bring about the
same problem if your text contains a double quote. The answer is to
double up your quotes, e.g.

Rst.FindFirst "[Section]='" & Replace(Me!NewSection,"'","''") & "'"

--
Error reading sig - A)bort R)etry I)nfluence with large hammer
Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.