T
Todd Huttenstine
You need square brackets [] around column/table names that have spaces:
[Employee Database]
[Employe ID]
MGFoster suggested I put brackets around my table name(above instructions).
I did that. For some reason it is still not working. Do I need to go into
ODBC management and do anything? This is my first time ever trying to
manipulate a database with code. Below is my new modified code. I get an
error on line objConn.Execute szSQL, , adCmdText Or adExecuteNoRecords.
Any help is greatly appreciated.
Dim objConn As ADODB.Connection
Dim szConnect As String
Dim szSQL As String
' Create the connection string.
szConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data
Source=C:\Employees.mdb;" & "Extended Properties=Excel 8.0;"
' Create the SQL statement.
szSQL = "INSERT INTO [Employees VALUES] ('Hetland', 'Camilla',
'Hagabakka 24', 'Sandnes')"
' Create and open the Connection object.
Set objConn = New ADODB.Connection
objConn.Open szConnect
' Execute the insert statement.
objConn.Execute szSQL, , adCmdText Or adExecuteNoRecords
' Close and destroy the Connection object.
objConn.Close
Set objConn = Nothing
' You 'll need to modify the connection string Data Source to point to
your
'Excel file and modify the SQL statement to fit your data.
Todd Huttenstine
[Employee Database]
[Employe ID]
MGFoster suggested I put brackets around my table name(above instructions).
I did that. For some reason it is still not working. Do I need to go into
ODBC management and do anything? This is my first time ever trying to
manipulate a database with code. Below is my new modified code. I get an
error on line objConn.Execute szSQL, , adCmdText Or adExecuteNoRecords.
Any help is greatly appreciated.
Dim objConn As ADODB.Connection
Dim szConnect As String
Dim szSQL As String
' Create the connection string.
szConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data
Source=C:\Employees.mdb;" & "Extended Properties=Excel 8.0;"
' Create the SQL statement.
szSQL = "INSERT INTO [Employees VALUES] ('Hetland', 'Camilla',
'Hagabakka 24', 'Sandnes')"
' Create and open the Connection object.
Set objConn = New ADODB.Connection
objConn.Open szConnect
' Execute the insert statement.
objConn.Execute szSQL, , adCmdText Or adExecuteNoRecords
' Close and destroy the Connection object.
objConn.Close
Set objConn = Nothing
' You 'll need to modify the connection string Data Source to point to
your
'Excel file and modify the SQL statement to fit your data.
Todd Huttenstine