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
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