Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / January 2007

Tip: Looking for answers? Try searching our database.

Find record problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gus Chuch - 06 Jan 2007 16:42 GMT
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
>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
[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]

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.