Solved

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

Posted on 2010-11-08
3
425 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 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

914 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

21 Experts available now in Live!

Get 1:1 Help Now