Need the code to replace " with its ascii to avoid errors in a sql statement.

Need the code to replace " with its ascii to avoid errors in a sql statement.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Please, send details
Chr$(34) is the double quote
Chr$(39) is the single

is this what you're asking for?
adamkushnerAuthor Commented:
"UPDATE Invoice SET LaborDescription = (" + Chr(34) + tempText + Chr(34) + ") WHERE InvoiceNumber = invoicenumber"

invoicenumber = key
tempText = textbox contents

I need to avoid errors due to double qoutes in the text box.  How do I go about this?
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Chage your Statement like below.

"UPDATE Invoice SET LaborDescription = """ & Replace(tempText, """", """ & chr(34) & """) & """ WHERE InvoiceNumber = invoicenumber"

Good Luck!

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
You don't have to change it to the ascii-code. Just replace ' by ''. This can be done by the easy statement replace

for example:
sql = "UPDATE Invoice SET LaborDescription = " & Replace(tempText, "'", "''") & "WHERE InvoiceNumber = " & invoicenumber


Chr$(34) is the double quote
Chr$(39) is the single

paste this code in vb module
Function QTrim(VVariant As Variant) As Variant
QTrim = Replace(Trim(VVariant), "'", "''")
End Function

'General sql statement using the Qtrim()
sql = "UPDATE Invoice SET LaborDescription = '" & Qtrim(Text1.text) & "' WHERE InvoiceNumber = " & invoicenumber

so every time you want to replace the ' to '' just use the qtrim(value) to do it.

easy and save time during the developing
adamkushnerAuthor Commented:
This was the only answer that used double qoutes as I asked.

Could you show me how to use a function like that but for double qoutes? Simply replacing the single with double doesn't work.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.