473,790 Members | 2,437 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CopyFromRecordS et 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
CopyFromRecords et 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 CopyfromRecordS et 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 6393
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 ReadDataFromAcc ess()

Dim cmd As New ADODB.Command, RS As New ADODB.Recordset
cmd.ActiveConne ction = "Provider = Microsoft.Jet.O LEDB.4.0; Persist
Security Info=false;Data Source=C:\Code\ testAcc\db1Test .mdb"
cmd.ActiveConne ction.CursorLoc ation = adUseClient
cmd.CommandText = "Select * from tbl1"
Set RS = cmd.Execute
Range("A1").Cop yFromRecordset 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.
TransferSpreads heet' 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
1614
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 it on a fourth machine (same versions of Excel & Access), no records are transfered (I check that the recordset contains records which it does). Any ideas?
3
9072
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 server, we are getting an Automation error (Error 430) when trying to use DAO CopyFromRecordset. It's your typical copyfromrecordset code: ObjSht.Range(.Cells(2, 1), .Cells(intMaxRow + 1, intMaxCol)).CopyFromRecordset rs
2
8874
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
1911
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
4706
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 upgrade, and didn't work afterwards. Research shows me the upgrade caused a problem with a memo field in the export, causing the CopyFromRecordset of object Range error. I found code that is supposed to fix it, but it either doesn't work, or I'm...
3
2150
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 an Oracle database. This has been working fine for two years and it still is working fine in our production environment. But after installing a new test server the problems started. I did many tests but there is something strange. When I start the...
1
3435
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 chart) I would like to place some records in to the underliing sheet and display the chart of this data using VBA. I use CopyFromRecordset. The code runs and the records are copied to the sheet, but apparently after this copy and before the next line...
0
1284
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 excel97 or excel2003 moved backend mdb tables to sql server2005 and relinked location field in both cases is a long integer but the above statement no longer works with either version of excel
11
10069
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 template, runs the query, then attempts to copy the query as a recordset into the Excel spreadsheet. The problem is that I get the following error when trying to use the CopyFromRecordset function: "Run-time error '430': Class does not support...
0
9666
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9512
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10413
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9021
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6769
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5422
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4094
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.