Access VBA insert a record with html tags

Getting an invalid syntax msg when I try to build an html tagged value string and insert it into a column.

Any suggestions for fixing this statement?  Do some of these characters require special handling?

strSQL = "Insert into [Session Detail Table] (Session) select ""<strong>"" & [Session Name] & ""</strong>"" & "" < br > "" FROM Import1"

Thanks for any suggestions
Who is Participating?
Boyd (HiTechCoach) Trimmell, Microsoft Access MVPConnect With a Mentor Commented:
When using " in a string you need to double them up like ""

Try this::

strSQL = "Insert into [Session Detail Table] (Session) select  ""<strong>" & [Session Name] & "</strong>< br >""  FROM Import1;"
Anthony BerenguelConnect With a Mentor Commented:
Try this.
strSQL = "Insert into [Session Detail Table] (Session) select " & chr(34) & "<strong>" & chr(34) & " " &  [Session Name] & " " & chr(34) & "</strong>" & chr(34) & " " & chr(34) & " < br > " & chr(34) & " FROM Import1"

Open in new window

TOWELLRAuthor Commented:
for some reason no matter how I build the insert it gives an error.
When I look at the insert statement it builds in a MsgBox it looks good.
Then it bombs with this error:

Run-time error '-2147467259 (800004005):
Method 'Execute' of object '_Connection' failed
Boyd (HiTechCoach) Trimmell, Microsoft Access MVPCommented:
Please post all the VBA code you are actually using for this task.
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.

All Courses

From novice to tech pro — start learning today.