Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 15th, 2005, 08:25 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
Default CopyFromRecordset and ADO.NextRecord

OK Team,

I need to retrieve five queries from (Stored Procedures) SQLserver and paste them onto five different worksheets. I thought I'd try to be clever and get all the data in one hit using the multiple recordset feature of ADO, and then loop through them, pasting each one to a new sheet using CopyFromRecordset.

The problem is that while the CopyFromRecordset for first recordset works fine, all subsequent sets complain about being closed. Is CopyFromRecordset meant to close recordsets? I could understand it setting EOF to true, but that should only affect the current set anyway.

Cheers,

Chris

There are two secrets to success in this world:
1. Never tell everything you know
__________________
There are two secrets to success in this world:
1. Never tell everything you know
 
Old March 28th, 2005, 11:27 AM
Registered User
 
Join Date: Mar 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Cris,

CopyFromRecordset dos't mean close recordsets.Make shore that you are itrating properly using recordset.NextRecordset or subsequent recordset are not blank

 
Old March 28th, 2005, 11:48 AM
Authorized User
 
Join Date: May 2004
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Just a thought: before Copying from the next recordset it may be usefull to execute the recordset.Movefirst, as the method begins with the current record.
It may also be helpfull to close the first recordset and set it to Nothing, freeing up some memory.

Mihai

 
Old March 28th, 2005, 11:50 AM
Authorized User
 
Join Date: May 2004
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

can you paste some code?






Similar Threads
Thread Thread Starter Forum Replies Last Post
runtime error when copyfromrecordset wuy Excel VBA 0 October 11th, 2007 09:16 PM
CopyFromRecordset Error maaron SQL Server ASP 1 April 17th, 2007 10:26 AM
Copyfromrecordset error using ADO maaron Excel VBA 0 August 11th, 2006 08:52 AM
VBA CopyFromRecordset and Excel JWag Pro VB Databases 0 April 12th, 2005 09:03 AM
CopyFromRecordset to Spreadsheet rweide SQL Server ASP 2 October 14th, 2004 03:56 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.