Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2010-11-08
3
Medium Priority
?
446 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
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…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

722 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