If I run the code it returns the recordset without any challenges. Subsequent to this bit of code I run another routine (does not include a recordset) to update a database table with a different connection string and then come back to run this code again. It is the second time that I get the error message.
Code: Select all
Dim CnBudget As ADODB.Connection
Dim rsBudget As ADODB.Recordset
Set rsBudget = New ADODB.Recordset
DeclareConnectionVariables
Set CnBudget = New ADODB.Connection
CnBudget.Open "Driver={SQL Server};Server=" & Server_Name & ";Database=" & Database_Name & _
";Uid=" & User_ID & ";Pwd=" & Password & ";"
CnBudget.CommandTimeout = 0
Application.Run "SQL_Build_Sequence_Routine"
CnBudget.Execute SQLStrSequence
Application.Run "SQL_Build_String"
CnBudget.Execute SQLStr
rsBudget.Open SQLStr, CnBudget, adOpenStatic
Cells(7, 2).CopyFromRecordset rsBudget 'Here is where the error message appears
rsBudget.Close
CnBudget.Close
Set rsBudget = Nothing
Set CnBudget = Nothing