Run Existing Access Query From Excel
I think I've answered my own question. Here is what I came up with using
ADO. It seems to work and it's about 100 times faster!
Sub RunAccessQueries_ADO()
Dim cn As ADODB.Connection
Dim cm As ADODB.Command
dbPath = "d:\data\mypath\"
dbName = "mydb.mdb"
Set cn = New ADODB.Connection
Set cm = New ADODB.Command
With cn
.CommandTimeout = 0
.Provider = "Microsoft.Jet.OLEDB.4.0;"
.ConnectionString = "Data Source=" & dbPath & dbName
.Open
End With
With cm
.CommandText = "DROP TABLE temp_tbl"
.CommandType = adCmdText
.ActiveConnection = cn
.Execute
'
.CommandText = "qryMakeTable"
.CommandType = adCmdStoredProc
.ActiveConnection = cn
.Execute
'
.CommandText = "qryAppend"
.CommandType = adCmdStoredProc
.ActiveConnection = cn
.Execute
'
End With
'
cn.Close
'
End Sub
|