Combo Name with '

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?
 
M

M Skabialka

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
 
B

BruceM

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.
 

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