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

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Forum statistics

Threads
1,136,420
Messages
5,675,737
Members
419,585
Latest member
popsin

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
Top