I am running this code to import from about 20 different databases. It works fine on all but 2!! This is the debug error that I get.
Run Time error '-214767259 (80004005)'
Method 'CopyFromRecordset' of Object 'Range' failed
And here is the code that I am running, I checked the database name, the file path and the query name and they are all correct, so I am at a loss as to what caused this to only go wrong on 2!
Public Sub GetAccessDataDAO()
c01 = "Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\Test\Test.mdb;"
With CreateObject("ADODB.Connection")
.Open c01
With CreateObject("ADODB.Recordset")
.Open "Select * from qry_check_time", c01, 3
Sheets(2).Rows(3).CopyFromRecordset .DataSource
.Close
End With
.Close
End With
End Sub
Edit:
It is also the exact same query from the other databases (of course just pulling from a different table) and this query will run w/o issues, if I open the database and run it, but for some reason the DAO just isn't taking or something like that. Also, the workbook has 2 sheets so that is not causing the issue either.
Bookmarks