473,473 Members | 1,816 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Escape % from VBA SQL String

124 New Member
How does one escape this % character from a VBA string used for searching in SQL? I get an error any time a SQL string with % is used for searching. I didn't even realize it was a reserved character in MS Access. I thought it was used in SQL Server as the Access equivalent of *, but apparently it is also used in Access. Also, what is the best way to escape single quotes within a string. Thanks in advance for responses.
May 25 '17 #1
1 2979
NeoPa
32,556 Recognized Expert Moderator MVP
Hi BikeToWork.

Actually, I believe the percent (%) can be used in Access as well as SQL Server SQL but only if the database is set to use ANSI-92 (File | Options | Object Designers | Query Design | SQL Server Compaitble Syntax (ANSI-92)). See ANSI Standards in String Comparisons for more on that.

When in use and not desired as a wildcard then any of these special characters (except quotes) can be matched if included within brackets ([]). So, to match 5% use '5[%]'.

For quote characters simply double them up. In a SQL string the string Donald O'Malley would be written as 'Donald O''Malley'. In a VBA string 5' 3" would be written as "5' 3""".
May 26 '17 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Sims | last post by:
Hi, I read somewhere that there are some tricks that a hacker can use to break into the db table. But how can i test against that? Is there a function to convert all strings to 'safe' strings?...
4
by: /dev/null | last post by:
Is there a function in php that you can pass a string headed for a mysql query and have it make it 'safe'? For example it would escape out the ' found in the string. Thanks!
2
by: Ksenia Marasanova | last post by:
Hi, I have a simple ecard creation script on a website, where user can add text to a graphic. I use ImageMagick for it: # template_file => path to image template file # new_file => path to...
1
by: Harry Keck | last post by:
Is there a set of methods in the .Net framework that do the same thing as the jscript functions escape and unescape? I get very close with HttpUtility.UrlEncodeUnicode, but it puts "+" for...
4
by: squash | last post by:
I have a string equal to 'www/' that I want to use in a preg_match. Php keeps giving me the warning: Warning: preg_match(): Unknown modifier '/' How can I escape the string so the / in www/ is...
3
by: qilin | last post by:
I am trying to save a big text string into MySQL, but I guess i need escape the string firstly, anybody knows any escape function in c for that? or any other suggests ?
5
by: andrei.avk | last post by:
Hi, I'd like to store chunks of text, some of them may be very large, in a database, and have them searchable using 'LIKE %something%' construct. These pieces of text may have single and double...
3
by: jmDesktop | last post by:
I have searched much but cannot find answer to this seemingly simple question. I have a function that builds an html element like this, which works fine: ...
14
by: Bennett Haselton | last post by:
I'm moving a bunch of PHP scripts from a server where they ran on PHP4, to a new server with PHP5. On the old server, variables in the query string would be automatically instantiated in the...
2
by: ylj798 | last post by:
this string from web by the Regular Expression$B!$(B $B!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!]!](B href="#" onClick="ConvertURL2FG('Flashget://...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.