LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy recordset from an Access "make table" query

I posted this as an Access question and have received no
responses, so I have decided that maybe this is more of
an Excel programming question. I am hesitant to duplicate
the posting, but I am stumped!

I have an application that has an Excel front-end where
some of the behind the scenes stuff happens in Access.
The user only sees Excel. Up to this point, data is
input and read into simple Access tables.

The latest revision requires some rather complex Access
queries. I have gotten everything working in the queries
as required, but now I need to get them into Excel using
VBA code.

The first thing I have to do is two "Make Table"
Queries. From these two tables, I then run another more
complex query. The make table queries are required every
time this procedure runs.

At this point, I am trying to output the new table to an
Excel Spreadsheet, just to make sure it is working.

The code is:

Set rst2 = New ADODB.Recordset

Src = "SELECT Materials.*, IIf(IsNull
([Materials.Color]),'~',[Materials.Color]) AS ColorMat
INTO tblMaterials FROM Materials;"

With rst2
.Open Source:=Src, ActiveConnection:=cnn
Set WDF = Worksheets("Delivery Forecast")
WDF.Range("A1").Offset().CopyFromRecordset rst2
End With

When I do this I get an error that says "Operation is not
allowed when Object is Closed."

The connection to Access seems fine, or I would not be
able to run the query. The error occurs when I try to
copy rst2 into Excel. Since the worksheet WDF cannot be
the object that the error is referring to, it must be the
recordset "rst2." I am assuming this is happening
because the table is new. How do I open this new table,
so I can copy the recordset? After the procedure has
run, how do I delete the new table?

Thanks,
Laurie

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding to excel "table" using external data query Irvine, Dennis Excel Discussion (Misc queries) 0 February 15th 08 10:06 PM
MS Query to Access table errors "do not have necessary permissions Al Excel Discussion (Misc queries) 0 February 8th 08 03:51 AM
Make pivot table with multiple "data" fields in columns not rows? cdomby Excel Discussion (Misc queries) 1 January 15th 07 04:54 PM
Pivot table "Show all data" query Laurence Lombard Excel Discussion (Misc queries) 2 January 31st 06 09:24 AM
Creating small "recordset" or sorting a numeric 1-dim array Anthony Cravero Excel Programming 0 December 19th 03 06:36 PM


All times are GMT +1. The time now is 01:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"