Solved

SQL INSERT error - Excel VBA/ADO/Access 2016

Posted on 2016-11-15
2
42 Views
Last Modified: 2016-11-15
I'm getting a strange error.
When I send this INSERT statement from Excel I get an error 'Syntax error in INSERT INTO statement'.

INSERT INTO tblRegularAttendance(ApplicationID, DayNumber, DayName, Session, RoleTitle, Hospital) VALUES('1234567',  4, 'Thursday', '4AM', 'Driver', 'Guys')

Open in new window

But when I run that in the Query Window in Access it runs ok!

The Connection is the same as I use for other ADO INSERT operations on this application.

Any ideas please?
Thanks
0
Comment
Question by:hindersaliva
2 Comments
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 41887814
what error you getting here? make sure you insert the values with same data types?
0
 
LVL 49

Accepted Solution

by:
Gustav Brock earned 500 total points
ID: 41887911
Perhaps Session is a reserved name, and spaces as shown:

INSERT INTO tblRegularAttendance (ApplicationID, DayNumber, DayName, [Session], RoleTitle, Hospital) 
VALUES ('1234567',  4, 'Thursday', '4AM', 'Driver', 'Guys')

Open in new window

/gustav
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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
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…

920 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