Hi Everyone, I'm struggling to understand an error I get when trying to create a new table into an existing Access database using excel vba code. Any help in understand how to overcome this error would be appreciated. this is the error I get:
"Run-time error '-2147217900 (80040e14)': Automation error"
clicking help sends me here: Automation error (Error 440)
below is my code:
"Run-time error '-2147217900 (80040e14)': Automation error"
clicking help sends me here: Automation error (Error 440)
below is my code:
Code:
Private Sub CommandButton1_Click()
Dim dbConnectStr As String
Dim cnt As ADODB.Connection
Dim dbPath As String
Dim tblName As String
'Set database name in the Excel Sheet
dbPath = "C:\Program Files\SETROUTE 9.2.0\DATA\REPORT.MDB" 'Database Name
tblName = "Cables721" 'Table Name
dbConnectStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & dbPath & ";"
'Connect to database and insert a new table
Set cnt = New ADODB.Connection
With cnt
.Open dbConnectStr
.Execute "CREATE TABLE " & tblName & " ([BankName] text(50) WITH Compression, " & _
"[C_ID] text(9) WITH Compression, " & _
"[LENGTH] text(10) WITH Compression, " & _
"[ELEVATION] text(150) WITH Compression"
End With
Set cnt = Nothing
End Sub