Results 1 to 45 of 45

Excel DAO import not working

Threaded View

  1. #1
    Forum Contributor
    Join Date
    06-18-2010
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    546

    Excel DAO import not working

    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.
    Last edited by jo15765; 02-06-2012 at 12:31 PM. Reason: Addional Info

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1