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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

text problem with access

Status
Not open for further replies.

BoxerBrats

Programmer
Jul 1, 2003
9
0
0
US
Hi, not sure how to phrase the question here so here it goes

On my program, a client made a entry usinf a apostaphy s (exp Mike's Rip Saw) when the program loads up, and see this database entry it freezes any ideas?
 
You really need to post more information.

does it do it if you run in teh VB ide? it sounds as though the string that is being passed to the database is not being parsed.

with a ' would need to be passed as '' so the database knows it is part of the string.


For example:

Code:
sqlstr = "Select afield From atable where acode = 'Mike's Rip Saw'"
when this is passed to the database the database sees the start single quote mark, then see's what it thinks is the end quote mark, which is in the name.

a simple way of doing the parsing is to do a replace on the variable that holds your search criteria.

Code:
strCriteria = replace(txtsearch.text,"'","''")

then use that to build your sql string

Code:
sqlstr = "Select afield From atable where acode ='" & strcriteria & "'"

hope this helps!

Matt

If you can keep your head while those around you are losing theirs, you obviously haven't grasped the seriousness of the situation
 
If you are using ADO take a look at using ADO parameters. See faq709-1526.

zemp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top