Issue with syntax in Insert query

Centrican

Board Regular
Joined
Dec 20, 2006
Messages
130
I am running the following query via VBA, to add a row to an access DB:

Code:
insert into ESOSdashboard (DashboardTimestamp, Proposals_Value, Proposals_No, QA_Value, QA_No, Contracted_Value, Contracted_No, Registered, Pending, Dead, OutOfScope, Contracted, Deferred, Live) values(#11/09/2014 19:54:26#, 2064653.75, 141, 1831520.25, 129, 10000, 1, 606, 563, 92, 0, 1, 1, 467)

The weird thing is that this is a query copied directly from the SQL viewer of the query in Access itself. Where it works.

What am I doing wrong, or what do I need to do differently?

The code to connect to the DB is:

Code:
    strDBpath = "\\helios3\home\team.all\business generation\esos process\database\esos register2.accdb"
    sConn = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
                             "Data Source=" & strDBpath & ";" & _
                             "Jet OLEDB:Engine Type=5;" & _
                             "Persist Security Info=False;"
    ' Open a connection.
    Set oConn = New ADODB.Connection
    errorcase = 4
    oConn.Open sConn


And finally this is the code to carry out the query:

Code:
oConn.Execute (strSQLinsert)

strSQLinsert is defined as the query at the top of this post.


Any help would be appreciated, I've run out of things to try.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Hi All,

It turned out all that was needed was adding brackets to the field names. Simple when you think about it.

Cheers
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,843
Members
449,051
Latest member
excelquestion515

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