Disabling apostrophe?

Chrisopia

Registered User.
Local time
Today, 04:47
Joined
Jul 18, 2008
Messages
279
I created a search tool and it would error whenever there was an apostrophe in their name... either company, first or last or even address.

I figured it was because of this part of the code:

Code:
Me.RecordsetClone.FindFirst " CompanyName = '" & Me.SearchBox & "'"

Where if there was an apostrophe it would cut the code short (i.e. the closing apostrophe of the string)

I need to prevent entries of apostrophe somehow... like an invalid key?

or a checking error? (like if someone typed O'Neil and tried to go to another control it would tell the user to remove the ')
 
Why don't you just double up the quotes like this:

Code:
Me.RecordsetClone.FindFirst " CompanyName = """ & Me.SearchBox & """"

That's 3 " after equal sign and 4 " at the end. Now it will accept O'Neil etc.


JR
 

Users who are viewing this thread

Back
Top Bottom