Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

INSERT INTO SQL works in Access query editor, but not in VBA using ADO

Posted on 2010-11-08
3
Medium Priority
?
454 Views
Last Modified: 2012-05-10
Hi Experts,

I am writing a query to insert a record into a Session table.

I can run the query from the Access SQL interface, but when I run it from VBA I get a "Syntax error in INSERT INTO statement".

Here is the srting from the immediate window: "INSERT into [SESSIONS] ([Sess_Start], [Sess_End], Username, UserID, Sess_Data, LanguageID, Locale, LastScreen, Usage, Success) VALUES (#08/11/2010 1:26:46 AM#, #08/11/2010 1:27:22 AM#, 'FinFlon', 9, 'SESSION_DATA_DUMP_08/11/2010 1:27:22 AM:SysUsage=OBSERVATION:Username=9:UserID=0:ObsSpecies=10:ObsCriteria=:ObsCentroidMap=:ObsDateDay=:ObsDateMonth=:ObsDateYear=:ObsDateUnknown=False:ObsQty=0:ObsNotes=:ENDDUMP=08/11/2010 1:27:22 AM:', 1, 1, 6, 1, False);"

Any help or ideas would be great.

Thanks,
0
Comment
Question by:WestCoastHip
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 34082938
remove the final ";"

also, change "false" to -1 ...
0
 
LVL 77

Expert Comment

by:peter57r
ID: 34083084
I can't see anything wrong with this sql, but I can reproduce your problem.

Instead of an ado command you could do it using :

Currentdb.execute strsql, dbfailonerror

which works OK.
0
 

Author Closing Comment

by:WestCoastHip
ID: 34083230
Thanks, I really appreciate your expertise. I was staring at that for hours.

0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

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

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

963 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