Combo Box Error 3077 - Access 2003

  • Thread starter Thread starter VikingFreddy
  • Start date Start date
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?
 
Back
Top