Solved

Run-time error '3077' when using an apostrophe in a name

Posted on 2002-07-19
4
354 Views
Last Modified: 2008-03-10
In Access 97, I have a user who has a few names, such as O'Brien and O'Ryan.  When she types in the name field to do a search, as soon as she types in "o" and presses ENTER, she gets the following:

"Run-time error '3077', syntax error (missing operator) in expression".

Here's the line of code it's stopping on:

Me.RecordsetClone.FindFirst "[strWholeName]= '" & Me![Combo40] & "'"

Any ideas??????
0
Comment
Question by:esu4236
  • 2
4 Comments
 
LVL 54

Accepted Solution

by:
nico5038 earned 100 total points
ID: 7165969
Try:

Me.RecordsetClone.FindFirst "[strWholeName]= " & chr(34) & Me![Combo40] & chr(34)

Nic;o)
0
 
LVL 2

Expert Comment

by:kiddiec
ID: 7166917
You need to create a function to replace the apos

such as the following

Function replaceApos(strToChk As String) As String
Dim X As Integer
Dim tmpstring As String
    For X = 1 To Len(strToChk)
    If Mid(strToChk, X, 1) <> "'" Then
        tmpstring = tmpstring & Mid(strToChk, X, 1)
    Else
        tmpstring = tmpstring & Mid(strToChk, X, 1) & "'"
    End If
Next

replaceApos = tmpstring
   
End Function


Then your code should read
Me.RecordsetClone.FindFirst "[strWholeName]= '" & replaceApos(Me![Combo40]) & "'"

This will double up the apostrophe's, you could enhance the function to include the item you are looking for such as (") which could return the corrected string
0
 

Author Comment

by:esu4236
ID: 7172236
nico5038,

Your solution worked great!!!!!!!!!!!   Thanks a bunch. Have a GREAT day.  
0
 
LVL 54

Expert Comment

by:nico5038
ID: 7172691
Glad I could help.

Success with your application.

Nic;o)
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
MS Access Bound Objects. 6 28
formattig excel from access 3 18
Resize text 4 16
Filtered index 5 0
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now