By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,317 Members | 1,265 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,317 IT Pros & Developers. It's quick & easy.

SQL with special characters...

P: n/a
Hi Gurus

What if you want to run SQL and you have a blob of text that you want to add
to a field and you have no idea how many "" or ' other characters are in
the text. Is there anyway you can run the sql (docmd.runsql) without
getting in trouble???

Right now, I open a hidden form, put the text in a control and then include
something like

forms!hiddenfrm!ctl

to identify the text.

TIA
-Nicolaas
Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Tue, 29 Jun 2004 11:27:17 +1200, "WindAndWaves" <ac****@ngaru.com>
wrote:

Write a function to replace funny characters by whatever the syntax
requires. E.g.
sql = "select * from tblContacts where LastName = '" &
ReplaceSubstring(forms!hiddenfrm!ctl, "'", "''") & "'"

This would replace ' with two of them, so a search for O'Brien would
be successful. Until database engines become more powerful, you have
to do the dirty work.

-Tom.
Hi Gurus

What if you want to run SQL and you have a blob of text that you want to add
to a field and you have no idea how many "" or ' other characters are in
the text. Is there anyway you can run the sql (docmd.runsql) without
getting in trouble???

Right now, I open a hidden form, put the text in a control and then include
something like

forms!hiddenfrm!ctl

to identify the text.

TIA
-Nicolaas


Nov 13 '05 #2

P: n/a
Tom van Stiphout wrote:
On Tue, 29 Jun 2004 11:27:17 +1200, "WindAndWaves" <ac****@ngaru.com>
wrote:

Write a function to replace funny characters by whatever the syntax
requires. E.g.
sql = "select * from tblContacts where LastName = '" &
ReplaceSubstring(forms!hiddenfrm!ctl, "'", "''") & "'"


Thereby skipping over the built-in Replace() function, hmmmm :-)

--
Error reading sig - A)bort R)etry I)nfluence with large hammer
Nov 13 '05 #3

P: n/a
That just seems really clumsy.

In my application, I use 100s of SQL statements and you never really know
what sort of characters you are going to encounter and how their behaviour
will be.

Thank you for your answer though.

Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.