I’m using this code to find a record and it works OK if the record has no
single quote mark like Tiny’s bar or Mark’s place. If any record has the
quote mark I get a run time error 3077
Syntax error missing operator in expression.
Is their a way to fix this or do I have to change all my records?
Private Sub Combo5_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[Name] = '" & Me![Combo5] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

Signature
thank You
RoyVidar - 06 Jan 2007 17:37 GMT
"Gus Chuch" <GusChuch@discussions.microsoft.com> wrote in message
<E2C59C87-F2BA-4BCC-8023-98B6EA7BB024@microsoft.com>:
> I’m using this code to find a record and it works OK if the record
> has no single quote mark like Tiny’s bar or Mark’s place. If any
[quoted text clipped - 10 lines]
> If Not rs.EOF Then Me.Bookmark = rs.Bookmark
> End Sub
Try one of the following
rs.FindFirst "[Name] = """ & Me![Combo5] & """"
or
rs.FindFirst "[Name] = '" & Replace(Me![Combo5], "'", "''") & "'"

Signature
Roy-Vidar
Marshall Barton - 06 Jan 2007 17:55 GMT
>Im using this code to find a record and it works OK if the record has no
>single quote mark like Tinys bar or Marks place. If any record has the
[quoted text clipped - 10 lines]
> If Not rs.EOF Then Me.Bookmark = rs.Bookmark
>End Sub
The old quoted quote problem. If none of your records has a
double quote character, you can use:
rs.FindFirst "[Name] = """ & Me![Combo5] & """"
If that's not guaranteed, then you can use either:
rs.FindFirst "[Name] = '" & Replace(Me!Combo5, "'", "''") &
"'"
Be sure to count those double quotes and apostrophes
carefully.
This alternative uses only double quotes and might be easier
to count:
rs.FindFirst "[Name] = """ & Replace(Me!Combo5, """",
"""""") & """"

Signature
Marsh
MVP [MS Access]