Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Appending using VBA but can't use an apostrophe in appended value 1

Status
Not open for further replies.

LeanneGodney

Technical User
Mar 7, 2002
175
GB
Hi there,

I am running the following code, which works a dream:

---
Dim cmd As New ADODB.Command

With cmd
.ActiveConnection = CurrentProject.Connection
.CommandText = "INSERT INTO dbo.tblTradeApprovalDetailsCaveats (TradeApprovalDetailsID, Caveat) VALUES (538, 'This is Kindve a test')"
.Execute
End With
---

Trouble is I would like to include an apostrophe in the word "kindve" = "kind've", but that messes up the command as an apostrophe is seen as the start and end of the text. Anyone know how to include an apostrophe in this text string without the apostrophe causing an error?

Thanks,
Leanne

 
Put two single quotes (NOT a double quote)

You can use Replace() to replace each single with two singles if you don't know whether the value contains a quote or not.
 
HI there,

Yes I was using the replace to replace an apostrophe with a `, whatever that is...

But two single quotes is exactly what I was after. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top