473,382 Members | 1,204 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

stripping quote characters?

Hey folks -

In vba, how do I get rid of quote characters in strings? Or at least escape
them automatically for making SQL INSERT statements? I looked in the help
index, but nothing jumped out at me.

Steve
Nov 12 '05 #1
3 1872
Look at the Replace function.
--
Terry Kreft
MVP Microsoft Access
"Steve Leferve" <le********@osu.edu> wrote in message
news:c6**********@charm.magnus.acs.ohio-state.edu...
Hey folks -

In vba, how do I get rid of quote characters in strings? Or at least escape them automatically for making SQL INSERT statements? I looked in the help
index, but nothing jumped out at me.

Steve

Nov 12 '05 #2

"Terry Kreft" <te*********@mps.co.uk> wrote in message
news:sf********************@karoo.co.uk...
Look at the Replace function.

Thanks, Terry. That's just what I needed.

Now I'm having problems replacing the Quote character with an empty string.
Shouldn't the below work? My strings still have extra quote characters.

If IsNull(rst!Comment10) Then
strSQL = strSQL & ""","""
Else
strSQL = strSQL & """" & Replace(rst!Comment10, Chr(34), "") & """,
"
End If
Nov 12 '05 #3
Yes, it should do, theonly thing I've found is that Replace (in early
versions at least) required the supposedly optional Compare argument.

So try

If IsNull(rst!Comment10) Then
strSQL = strSQL & ""","""
Else
strSQL = strSQL & """" & Replace(rst!Comment10, Chr(34), "",
compare:=vbBinaryCompare) & ""","
End If

Or if you want to get rid of the If statement you could just use

strSQL = strSQL & """" & _
& Replace(rst!Comment10 & "", Chr(34), "",
compare:=vbBinaryCompare) & ""","
--
Terry Kreft
MVP Microsoft Access
"Steve Leferve" <le********@osu.edu> wrote in message
news:c6**********@charm.magnus.acs.ohio-state.edu...

"Terry Kreft" <te*********@mps.co.uk> wrote in message
news:sf********************@karoo.co.uk...
Look at the Replace function.

Thanks, Terry. That's just what I needed.

Now I'm having problems replacing the Quote character with an empty

string. Shouldn't the below work? My strings still have extra quote characters.

If IsNull(rst!Comment10) Then
strSQL = strSQL & ""","""
Else
strSQL = strSQL & """" & Replace(rst!Comment10, Chr(34), "") & """, "
End If

Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: joram gemma | last post by:
Hello, on windows python 2.4.1 I have the following problem >>> s = 'D:\\music\\D\\Daniel Lanois\\For the beauty of Wynona' >>> print s D:\music\D\Daniel Lanois\For the beauty of Wynona >>>...
15
by: Jeff North | last post by:
Hi, I'm using a control called HTMLArea which allows a person to enter text and converts the format instructions to html tags. Most of my users know nothing about html so this is perfect for my...
2
by: David Pratt | last post by:
I am working with a text format that advises to strip any ascii control characters (0 - 30) as part of parsing data and also the ascii pipe character (124) from the data. I think many of these...
3
by: Steve Leferve | last post by:
Hey folks - In vba, how do I get rid of quote characters in strings? Or at least escape them automatically for making SQL INSERT statements? I looked in the help index, but nothing jumped out at...
4
by: Lu | last post by:
Hi, i am currently working on ASP.Net v1.0 and is encountering the following problem. In javascript, I'm passing in: "somepage.aspx?QSParameter=<RowID>Chèques</RowID>" as part of the query...
7
by: Edward Elliott | last post by:
I'm looking for the "best" way to strip a large set of chars from a filename string (my definition of best usually means succinct and readable). I only want to allow alphanumeric chars, dashes,...
7
by: FFMG | last post by:
Hi, I have a form that allows users to comment, add entries and so on. But what a lot of them do is copy and paste directly from MS Word to my forms. almost all browsers will accept the post...
2
by: Big Moxy | last post by:
I want to send html formatted text yet strip out special characters (e.g. quotes and semi colons). I've seen preg_replace examples like $messageout = preg_replace('/\(\)<>]/i','',$message); to...
11
by: Lo'oris | last post by:
I'd like to have a set of "allowed characters", and strip a string from everything besides those. I've tried and tried but so far every time I enter strings containing unicode, it goes mad and...
4
by: Tim Cook | last post by:
Hi All, I just ran into an issue with the rstrip method when using it on path strings. When executing a function I have a need to strip off a portion of the current working directory and add...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.