Apostrophe problem in filter.

sdawson

Registered User.
Local time
Today, 19:47
Joined
Apr 22, 2003
Messages
165
I’m using a combo box to select real names and using the following event to filter
Private Sub Combo45_Click()
Me.Filter = "[CustomerName] = '" & [Combo45] & "'"
Me.FilterOn = True
Me.GHSpickups.SetFocus
End Sub

Simply stuff so far.

The problem is a real name such as O’Reilly gives a problem because of the apostrophe.
Any way round this would be welcome.
 
You won't have this problem if you use a stored query to base your form on and use Combo45 as a criterion in the query. Then you don't need the filter in the form.
 
Another options is to use double quotes to delimit rather than single quotes:
Me.Filter = "[CustomerName] = """ & [Combo45] & """"
or
Me.Filter = "[CustomerName] = " & Chr(34) & [Combo45] & Chr(34)
 
Thanks chaps.
The double quotion marks did it for me.

What's puttering RuralGuy?
 
Oh, I do that too with great flair.
Cheers.
 

Users who are viewing this thread

Back
Top Bottom