Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Single quote's?? 1

Status
Not open for further replies.

Junior1544

Technical User
Apr 20, 2001
1,267
US
I have a form with people's name. some people have a ' in their last name. how can i have a form accept this?? i have a search form that i need this to work for, and i have no idea where to start... thanks

--Junior JHauge@jmjpc.net
Life is change. To deny change is to deny life.
 
Jr, this is a sticky wicket. I think what you'll need to do is check for the existence of a single quote in the entered-search string, e.g. "The O'kays" and if there is one, toss two others, one on either side of it, still within the set of double quotes, so your search string ends up looking like this:

"The O'''kays"

Test it - you'll need either three or four singles in there to keep from getting mis-parsed...

Jim

There are two ways to argue with a woman - neither one works.
Another free Access forum:
More Access stuff at
 
would i be able to just stick '' around the whole thing?? like this (re your example)

"'The O'kays'"

that way i can just put it around my var, and it'll work out??

--Junior JHauge@jmjpc.net
Life is change. To deny change is to deny life.
 
yea, access didn't like that... i was just playing in the accual form, the way a user would see it... and when i put in two single's, it takes it and finds the record... how would i go about programming the form, so that when a single quote is put in, it just add's another one into the variable??

--Junior JHauge@jmjpc.net
Life is change. To deny change is to deny life.
 
I think you may need to split it, and then join the left and right parts around the single quote:

UserString: The O'Kays

First, find the single quote:

SQ - instr(UserString, "'")

LeftPart = Left(UserString, 1, SQ-1)

RightPart = Mid(UserString, SQ+1)

UserString = LeftPart & "'" & RightPart

You SHOULD then be able to send this string to your search routine and not have it barf...

Jim



There are two ways to argue with a woman - neither one works.
Another free Access forum:
More Access stuff at
 
i found an easier way late last night...

vb uses " (doubles) to see a string... and the singles (') for a string inside a string... i found a thread in here from a long time ago... you can change single quotes (denotes a sub string) to two double quotes ("") and then the string will see single quotes without a problem...

just wanted to pass this... even though it'll make looking at the code a little harder, you can see that it makes it much easier for the user...

--Junior JHauge@jmjpc.net
Life is change. To deny change is to deny life.
 
If it's not a problem a simple way around this is to change the ' with ` in the table, so you would get O`Malley instead of O'Malley and the search will work OK.
 
i already have a lot of pre existing data, plus people that don't take to change very well... so i have already implimented the last message i put up there, and every thing is working very well...

--James
JHauge@jmjpc.net
Life is change. To deny change is to deny life.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top