Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

run-time Error '3077'

Status
Not open for further replies.

uipuih

Technical User
Jan 30, 2009
6
US
Having problems when my combo lookup box comes across an apostrophe. below is my code.
Private Sub Combo11_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Guarantor] = '" & Me![Combo11] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

I have looked at previous posts where suggestions have me try to replace the ' with " and also the code that suggests placing replace in front of Me!. but no success.

 
Try double quoting;

[tt]rs.FindFirst "[Guarantor] = """ & Me![Combo11] & """"[/tt]

Roy-Vidar
 
thanks,
I copied and pasted your code it works fine. I tried this earlier but must have been missing something. appreciate your assistance.
 
Another (safer) way:
Code:
rs.FindFirst "Guarantor='" & Replace(Me![Combo11], "'", "''") & "'"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Safer using DAO .findfirst - how is that, if I may ask?

Roy-Vidar
 
Suppose that the searched string contains a double quote

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hm, I guess my preference for the replace method, and not searching by lookup value, but rather index/PK, has saved me from such problems. Thanx.

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top