473,434 Members | 1,510 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,434 software developers and data experts.

CopyFromRecordSet doesn't on DAO in Access 2007?

Does anyone else have the same issue?
I'm using Access 2007 and trying to export a DAO recordset to excel using
CopyFromRecordset but I systematically get a "Run-Time error 430, Class does
not support Automation or does not support expected interface".
When I use ADO, it works fine.

Everything is up-to-date on my PC, doesn't seems to be any broken references,
and everywhere I look, it says that CopyfromRecordSet should work with both
ADO and DAO, yet it clearly doesn't.

So anyone has more information on this, shared the same experience or can
confirm that I'm not alone with this issue?

Thank you,
--
Renaud Bompuis
http://blog.nkadesign.com
http://etc.nkadesign.com

Sep 5 '07 #1
2 6362
The following subroutine is run from an Excel code module and uses a
Reference to the Microsoft ActiveX data objects library 2.+ (can use 2.1
through 2.8)

Sub ReadDataFromAccess()

Dim cmd As New ADODB.Command, RS As New ADODB.Recordset
cmd.ActiveConnection = "Provider = Microsoft.Jet.OLEDB.4.0; Persist
Security Info=false;Data Source=C:\Code\testAcc\db1Test.mdb"
cmd.ActiveConnection.CursorLocation = adUseClient
cmd.CommandText = "Select * from tbl1"
Set RS = cmd.Execute
Range("A1").CopyFromRecordset RS

End Sub

DAO works great inside Access -- easier to use than ADO for manipulating
Access tables/Access dataobjects. But from Excel -- ADO is easier/more
reliable to use for database operations (with Access/sql server/oracle).

DAO is my data access model of choice when I am working within Access
with Access data (data contained in Access tables). But if data resides
anywhere outside of Access (sql Server, Excel...) ADO is my data access
model of choice -- including from within Access.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Sep 5 '07 #2
Hi Rich,

I know it works fine with ADODB but I'm using DAO in my application.
My aim was to simply pass a DAO RecordSet to a sub that would export the
content of the recordset to Excel.
I know I can export queries and form content to Excel using 'DoCmd.
TransferSpreadsheet' or 'DoCmd.OutputTo', but in my case I'm trying to export
a subform in datasheet mode whose RecordSource is modified in code. The
purpose of this was to export the data viewed by the user to a spreadsheet.
Turns out it's a lot harder than I expected in my case as:
- I'm not using a named query but a SQL statement that I modify on the fly,
so I cannot pass it to the DoCmd methods as they expect named queries.
- my SQL statement is based on another query that is dependent on the value
of a combobox on the main form, and it seems that using ADODB doesn't
correctly interpret that (it keeps generating an error saying that a
parameter value hasn't been provided, even though it works fine in DAO).
- the data I want to export being on a subform, 'DoCmd.outputTo acForm' only
exports the main form, not the subform. I even tried to get a fully qualified
name for the subform to no avail: it only wants a form name, not the name of
a form instance.

Instead, I'll have to reinvent the wheel and code a sub that will take a
form's reference and output an excel file matching the form's datasheet
layout.

That's Access and VBA for me... ;-(

--
--
Renaud Bompuis
http://blog.nkadesign.com
http://etc/nkadesign.com

Message posted via http://www.accessmonster.com

Sep 6 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: info | last post by:
I have an Access Application which happily uses CopyFromRecordset to transfer values from an access query via a recordset to an excel spreadsheet, this works on three machines. However, when I try...
3
by: Sarah | last post by:
I know there have been plenty of posts online about this issue, but I have yet to find a solution. I am desperate for a good answer. The issue is: with newly-built PCs and, as it happens, our web...
2
by: al | last post by:
Greetings, I'm wondering if Excel object CopyFromRecordset is still supported in VB.NET?? If not, what is the alternative, looping through dataset???? MTIA, Grawsha
4
by: Allthumbs | last post by:
Hi, Both laptops seem to have the same set up office 2002 and windows XP. But copyfromrecordset works fine on one PC and fails in another. It does not throw any exception. Help!! thanks,
2
by: zhollywood | last post by:
OK... I'm not VBA illiterate, but I'm a BA trying to maintain a code-heavy Access 2002 (XP OS) front-end attached to Oracle tables. I have an export to Excel button that worked before the SP2...
3
by: Cor Pruim | last post by:
I have a very strange problem. I have written a Windows Service with VS2003 in vb.net. This service does some calculations and after that it needs to produce some Excel reports by getting data from...
1
by: il0postino | last post by:
Apologies in advance for this newbie question! I have an Access form with an unbound embedded Excel chart on it(Called, OLEUnbound39) (Done on Access form by Insert > Object > Microsoft excel...
0
by: Roger | last post by:
can anyone explain this ? originally using access97 with a linked table to an mdb backend, to create a worksheet using SELECT * FROM qryIPS WHERE location = 999 and it works fine with either...
11
by: mac6777 | last post by:
I am having a problem with the CopyFromRecordset function in VBA Access. I am attempting to run VBA in an Access Database that copies query results into an Excel spreadsheet. The VBA opens an Excel...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.