MrExcel Publishing
Your One Stop for Excel Tips & Solutions

DAO CopyFromRecordSet

Posted by John Borders on December 12, 2001 7:24 AM

I have created a reference to DAO object library 3.6
and have been successful in opening an Access database using an Excel macro. However when I do to copy a table from the database into Excel, I only get one record from the table, not all of them. I am using
[A2].CopyFromRecordset rst
the error msg is: Method 'CopyFromRecordSet' of object 'Range' failed.
Any idea why it stops after copying only one record?

Posted by Dank on December 12, 2001 8:25 AM


It's hard to diagnose your problem without seeing the rest of your code. Could you post it?


Posted by John Borders on December 12, 2001 12:24 PM

Yes, Thank you very much for taking a look at it. Here it is:
Dim dbs As Database, rst As Recordset
Set dbs = OpenDatabase("c:\winnt\profiles\jborders\desktop\northwinds.mdb")
Set rst = dbs.OpenRecordset("Employees", dbOpenDynaset, dbReadOnly)
[A2].CopyFromRecordset rst