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

stripping quote characters?

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a

"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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.