Syntax error INSERT INTO keeps occurring.

banspat91

New Member
Joined
Dec 5, 2017
Messages
1
Hi everyone,
I'm currently working on a project where I want data taken from an excel table imported into an access database. The excel table cannot be linked to the access. This is the code I am currently using:


Sub AccImport()





Set cn = CreateObject("ADODB.Connection")
dbpath = Application.ActiveWorkbook.Path & "\PCN Database.accdb"
dbWb = Application.ActiveWorkbook.FullName
dbWs = Application.ActiveSheet.Name
scn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & dbpath
dsh = "[" & "exportdata" & "$]"


cn.Open scn

ssql = "INSERT INTO PCN Database([PCR NO:],[Product Code/Item Number],[Product Description/Item Description],[Extra Description],[Net Net Wgt/CS (Paper ONLY)],[New Product],[Current Product Change],[Product Discontinued],[Consumer],[Home & Office],[Private Label],[Service],[Street],[Shipping Container Code (if Bundle 1st 2 bxs are Zeros)],[Level 2 - Inner Poly/Wrap UPC (Multi Pack/Bundles)],[Level 1 - Inner Most Poly/Wrap UPC],[Plant NJ],[Plant VT],[Plant Outsourced],[Item Class],[Item Type],[Estimated Initial Production Date],[Size of Paper L x W *],[No of Sheets (UNSZ)],[Basis Weight*],[Noof Plies*],[Print and % *],[Paper Grade *],[Package/Selling Unit(PACKAGING SIZE)]"




ssql = ssql & "SELECT * FROM [Excel 16.0 ;HDR=YES;DATABASE=" & dbWb & "]." & dsh
cn.Execute ssql










End Sub



Thank you
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Forum statistics

Threads
1,214,782
Messages
6,121,532
Members
449,037
Latest member
tmmotairi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top