Reuse a Recordset - not working, any rules i dont know?

uofmoo

New Member
Joined
May 7, 2006
Messages
19
I am trying to reuse a recordset and it is giving me a hard time.

Code:
Dim CXN1 As ADODB.Connection
Dim RS1 As ADODB.Recordset

Set CXN1 = New ADODB.Connection
CXN1.ConnectionString = "Provider=SEQUEL ViewPoint;"
CXN1.Open
Set RS1 = New ADODB.Recordset
RS1.Open "MYSERVER/MYLIBRARY/MY_SCRIPT", CXN1
RS1.Close
RS1.Open "MYSERVER/MYLIBRARY/MY_QUERY", CXN1
Sheets("Data").Activate
Range("A" & my_row_variable + 1).CopyFromRecordset RS1
RS1.Close
RS1.Open "MYSERVER/MYLIBRARY/MY_QUERY2", CXN1
Sheets("Data2").Activate
Range("A" & my_second_row_variable + 1).CopyFromRecordset RS1
RS1.Close
CXN1.Close
Set RS1 = Nothing
Set CXN1 = Nothing

It runs the script fine, and the first query fine - returns results as expected. However when it tries to reuse the recordset i get all sorts of errors - have tried a few different ways but no luck. Any help appreciated. Thanks!!

Amy
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Forum statistics

Threads
1,214,920
Messages
6,122,267
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top