Solved

SQL INSERT error - Excel VBA/ADO/Access 2016

Posted on 2016-11-15
2
25 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

705 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

12 Experts available now in Live!

Get 1:1 Help Now