I have a line in an email text that has single quotes in it like this:
EmailText = "This is an 'example' of the text."
Then when I run this:
DoCmd.RunSQL "UPDATE tblEmailings SET tblEmailings.Body = " & EmailText & ";"
It errors out and I'm sure it's because of the single quotes in the EmailText.
How do I get around this? A web search has proved to be unhelpful.
Thanks,
Laura
I have a line in an email text that has single quotes in it like this:
EmailText = "This is an 'example' of the text."
Then when I run this:
DoCmd.RunSQL "UPDATE tblEmailings SET tblEmailings.Body = " & EmailText & ";"
It errors out and I'm sure it's because of the single quotes in the EmailText.
How do I get around this? A web search has proved to be unhelpful.
Thanks,
Laura
On Friday, December 18, 2020 at 10:22:25 AM UTC-6, musicloverlch wrote:
I have a line in an email text that has single quotes in it like this:
EmailText = "This is an 'example' of the text."
Then when I run this:
DoCmd.RunSQL "UPDATE tblEmailings SET tblEmailings.Body = " & EmailText & ";"
It errors out and I'm sure it's because of the single quotes in the EmailText.
How do I get around this? A web search has proved to be unhelpful.
Thanks,Replace will work for the 1 character, but others can cause problems.
Laura
if the text is no more then 255 characters use a parameter query, which will allow any text.
Dim updateBody As DAO.QueryDef
Set updateBody = CurrentDb.CreateQueryDef(vbNullString, "PARAMETERS [newBody] Text ( 255 ); UPDATE tblEmailings SET tblEmailings.Body = [newBody];")
updateBody.Parameters(0) = "This is an 'example' of the text." updateBody.Execute
Set updateBody = Nothing
If it is a memo, a recordset may work.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 296 |
Nodes: | 16 (2 / 14) |
Uptime: | 84:24:46 |
Calls: | 6,658 |
Calls today: | 4 |
Files: | 12,203 |
Messages: | 5,333,601 |
Posted today: | 1 |