SQL Insertion

  • Thread starter Thread starter JimS
  • Start date Start date
J

JimS

I'm accepting search criteria from text boxes, so it'll set the filter to
something like

Me.Filter="Description like '*" & tbDesc & "*'"

Seems to work if tbDesc contains double quotes, but blows up if tbDesc
contains single quotes...

Can I use:

Me.Filter="Description like '*" & replace(tbDesc,"'","''") & "*'"

and have it work when the user enters single quotes?
 
Yes.

Hopefully you tried it, rather than waiting for someone to respond...
 
The usual reason that kind of action gets that error is when you run into a
name like O'Hare. Use double-quotes as the delimiter instead of
single-quotes. Although this still causes a problem if the field contains a
double-quote, that occurs far less often.
Try using double quotes, like this:
stLinkCriteria = "[Engineer Name]=""" & Me![Firm Contact] & """"
Also:
"This string contains a ""double-quoted"" word."


This is a good resource:
http://www.mvps.org/access/general/gen0019.htm

This is good:
http://allenbrowne.com/casu-17.html



HTH,
Ryan---
 
You're right, Doug, I did try it and it worked.

The issue is that the descriptions often contain double quotes to represent
inches, and rarely will contain a single quote to represent feet.

Ryan, thanks for the resources!

--
Jim


ryguy7272 said:
The usual reason that kind of action gets that error is when you run into a
name like O'Hare. Use double-quotes as the delimiter instead of
single-quotes. Although this still causes a problem if the field contains a
double-quote, that occurs far less often.
Try using double quotes, like this:
stLinkCriteria = "[Engineer Name]=""" & Me![Firm Contact] & """"
Also:
"This string contains a ""double-quoted"" word."


This is a good resource:
http://www.mvps.org/access/general/gen0019.htm

This is good:
http://allenbrowne.com/casu-17.html



HTH,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


JimS said:
I'm accepting search criteria from text boxes, so it'll set the filter to
something like

Me.Filter="Description like '*" & tbDesc & "*'"

Seems to work if tbDesc contains double quotes, but blows up if tbDesc
contains single quotes...

Can I use:

Me.Filter="Description like '*" & replace(tbDesc,"'","''") & "*'"

and have it work when the user enters single quotes?
 

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

Back
Top