Lookup Combo Box Problem! Help!

Bachfile

Registered User.
Local time
Today, 04:04
Joined
Jul 4, 2002
Messages
41
I just discovered an interesting bug in the code I was using to find a record matching a control.

I get a run time error (#3077) that states that there has been a "syntax error (missing operator) in expression."

Here is a copy of the procedure that governs the combo box.

Private Sub Combo11_AfterUpdate()

Dim rs as object
Set rs = Me.Recordset.Clone
rs.FindFirst "[DonorName] = '" & Me.[Combo11] & "'"
Me.Bookmark = rs.Bookmark

There error only appears when the record selected has a ' as part of its value.
For example, selecting the record O'Conner, John causes this error as well as O'Fee, James.
Records that do not contain a ' have not caused any problems.

Thank you all very much for any help you can offer!
 
Replace the single quote with double quotes whenever a string might contain single quotes.

rs.FindFirst "[DonorName] = """ & Me.[Combo11] & """""
 

Users who are viewing this thread

Back
Top Bottom