Solved

Access VBA insert a record with html tags

Posted on 2013-11-14
4
299 Views
Last Modified: 2013-11-18
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
0
Comment
Question by:TOWELLR
  • 2
4 Comments
 
LVL 10

Assisted Solution

by:Anthony Berenguel
Anthony Berenguel earned 250 total points
ID: 39648771
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

0
 
LVL 21

Accepted Solution

by:
Boyd (HiTechCoach) Trimmell, Microsoft Access MVP earned 250 total points
ID: 39648961
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;"
0
 

Author Comment

by:TOWELLR
ID: 39650006
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
0
 
LVL 21
ID: 39650252
Please post all the VBA code you are actually using for this task.
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now