Error 3077 with ComboBox

G

Guest

I have a combo box which looks up records in a table by user name, and
returns the data to the form. There is one user whose last name has an
apostrophe in it (i.e. O'Healy), and whenever I select this name from the
combo box I receive the following error:

Run-time '3077'

Syntax error (missing operator) in expression.

I'm almost certain that this error occurs because of the apostrophe in the
name (I don't receive an error when selecting other individuals from the
combo box), but I'm not sure how to resolve this issue.

Any suggestions would be appreciated.

Thanks,
Manuel
 
R

RoyVidar

Manuel said:
I have a combo box which looks up records in a table by user name,
and returns the data to the form. There is one user whose last name
has an apostrophe in it (i.e. O'Healy), and whenever I select this
name from the combo box I receive the following error:

Run-time '3077'

Syntax error (missing operator) in expression.

I'm almost certain that this error occurs because of the apostrophe
in the name (I don't receive an error when selecting other
individuals from the combo box), but I'm not sure how to resolve
this issue.

Any suggestions would be appreciated.

Thanks,
Manuel

It's usually easier to assist when one also has some code to play with,
knowing which line it bombs on etc...

When passing the criterion to the .findfirst, try either

....myfield = """ & me!cboMyCombo.Value & """"

or

....myfield = '" & replace(me!cboMyCombo.Value, "'", "''") & "'"

using your own field/control names. If it doesn't help, please post
your code.
 
G

Guest

Sorry about that... here's the code... the combo wizard wrote the code...

Private Sub EmployeeNameLookUp_AfterUpdate()

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

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

End Sub

The code bombs out on the line that starts with:

rs.FindFirst "[Employee Name]
 
R

RoyVidar

Manuel said:
Sorry about that... here's the code... the combo wizard wrote the
code...

Private Sub EmployeeNameLookUp_AfterUpdate()

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

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

End Sub

The code bombs out on the line that starts with:

rs.FindFirst "[Employee Name]

I'm afraid that if my previous suggestion didn't work, I'm not sure
what
to do - but from what you pasted, it doesn't seem you tried.

Could you please try one (or both) of my previous suggestions, then
report back if it/they don't work?
 
G

Guest

Your 1st suggestion worked! Thanks a bunch!
Manuel

RoyVidar said:
Manuel said:
Sorry about that... here's the code... the combo wizard wrote the
code...

Private Sub EmployeeNameLookUp_AfterUpdate()

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

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

End Sub

The code bombs out on the line that starts with:

rs.FindFirst "[Employee Name]

I'm afraid that if my previous suggestion didn't work, I'm not sure
what
to do - but from what you pasted, it doesn't seem you tried.

Could you please try one (or both) of my previous suggestions, then
report back if it/they don't work?
 

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

Top