Combo Name with '

  • Thread starter Thread starter cpamxn
  • Start date Start date
C

cpamxn

Sub Combo61_AfterUpdate()
' Find the record that matches the control.
Me.RecordsetClone.FindFirst "[Unit] = '" & Me![Combo61] & "'"
Me.Bookmark = Me.RecordsetClone.Bookmark
End Sub

I want to use a cmbo box to search for a record on a form.

If a record in the table has a apostrophe ' as in "albert's office", I get
an error message. How can I get around this?
 
Is there a unique primary key (e.g. ID) you can use instead? Have a 2
column combo - the ID can be invisible to the user, and search on the ID
instead.
Me.RecordsetClone.FindFirst "[ID] = " & Me![Combo61].Column(1)
Column(0) is the first column!
Mich
 
Replace the apostrophe in the code with a pair of quote marks:

Me.RecordsetClone.FindFirst "[Unit] = """ & Me![Combo61] & """"

If there is a quote mark in the field (Albert's "Big Al's" office) you will
need another approach, but I'll leave that aside unless you mention a need
for it.
 
Back
Top