Combo Box Error 3077 - Access 2003

V

VikingFreddy

I am using to following code to select a record from a combo box:

Private Sub cboFindName_AfterUpdate()

' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Name] = '" & Me![cboFindName] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

End Sub

This works fine until there is an apostrophe in the record when it fails with:

Runtime error '3077': Syntax error (missing operator) in expression.

This is obviously due to using single quotes after [Name] = and then putting
the closing single quote inside a pair of double quotes after the
[cboFindName], the apostrophe in the record is being read as the closing
quote. I am totally lost as to what sequence of quotes to use so that this
error doesn't occur.

Can anyone point me in the right direction please?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Run time error 3077 1
Search combo box 2
Error 2147352567 2
RunTime Error 3070 11
Combo Box Syntax Error 1
List Box Error 1
Run Time error 3077 1
Error 2237 8

Top