combo box (using a selection to search a database)

mikeco555

Registered User.
Local time
Today, 16:55
Joined
Jan 23, 2004
Messages
22
I have an access database that on my interface I use a combo box to allow a user to scroll to the record he or she desires and when clicked it populates the appropriate fields on the form.
Everything works just fine except when the name highlighted in the combo box has an apostraphie (') such as: O'Brien.

When I do select a name such as O'Brien VB errors out to this subprocedure in my code, giving me a syntax error-- '3077' missing opperator in expression-- Here is my code.

Could anyone please tell me how to get around the issue of apostraphies in combo boxes.

code:

Private Sub Combo22_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[PATIENT] = '" & Me![Combo22] & "'"
Me.Bookmark = rs.Bookmark
End Sub

Thanks,
Mike
 
Try changing this line:
rs.FindFirst "[PATIENT] = '" & Me![Combo22] & "'"
to:
rs.FindFirst "[PATIENT] = """ & Me![Combo22] & """
 
thank you dcx693
I tried the code you sent and it worked.
I really appricate it.
 

Users who are viewing this thread

Back
Top Bottom