Sub CreateTable()
MsgBox "Like this?"
'Add Reference to Microsoft ActiveX Data Objects 2.x Library
Dim strConnectString As String
Dim objConnection As ADODB.Connection
Dim strDbPath As String
Set objConnection = CreateObject("ADODB.Connection")
'Set database name and DB connection string--------
strDbPath = "E:\Books\Works\Newdb.mdb"
'==================================================
MsgBox "created"
strConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDbPath & ";"
MsgBox "created2"
'Connect Database; insert a new table
'Set objConnection = New ADODB.Connection
With objConnection
.Open strConnectString
.Execute "CREATE TABLE MyTable ([EmpName] text(50) WITH Compression, " & _
"[Address1] text(150) WITH Compression, " & _
"[Address2] text(150) WITH Compression, " & _
"[City] text(50) WITH Compression, " & _
"[State] text(2) WITH Compression, " & _
"[PIN] text(6) WITH Compression, " & _
"[SIN] decimal(6))"
End With
End Sub
以下のようなエラーが表示されます
****Run-Time Error '-2147467259 (80004005)':
Automation error
Unspecified error****