Hello,
This is my first time trying to create a recordset from a SQL Server Stored Procedure. I expect one record returned with about fifteen columns. I will then take the columns and populate a form's textbox with the value or a null.
When I get to the IF loop I get the following error:
Runtime error '3704' Operation not allowed when the object is closed.
Here is the code: (the rstTeamDates has been set as a New ADODB.Recordset at the beginnning of the Sub) and cnnASPIRE is a connection string in the Form Load.
If I run the Stored Procedure from an Access Pass Through query (exec sp_CombinedEventActualCycleTime 5713) In my code the EventProfileID is equal to 5713 as I step through the code.
Please show me the error of my ways!
Thanks, Troy
This is my first time trying to create a recordset from a SQL Server Stored Procedure. I expect one record returned with about fifteen columns. I will then take the columns and populate a form's textbox with the value or a null.
When I get to the IF loop I get the following error:
Runtime error '3704' Operation not allowed when the object is closed.
Here is the code: (the rstTeamDates has been set as a New ADODB.Recordset at the beginnning of the Sub) and cnnASPIRE is a connection string in the Form Load.
Code:
Dim cmd As New ADODB.Command
With cmd
.ActiveConnection = cnnASPIRE
.CommandType = adCmdStoredProc
.CommandText = "dbo.sp_CombinedEventActualCycleTime"
.Parameters("@RTEventID") = EventProfileID
Set rstTeamDates = .Execute
End With
If rstTeamDates.RecordCount > 0 Then 'This is where I get the error when stepping through the code...
If IsDate(rstTeamDates(0)) = True Then
SummaryActualSoldNot = rstTeamDates("SoldNotificationReceivedDate")
Else
SummaryActualSoldNot = Null
End If
If IsDate(rstTeamDates("RequirementsCompleteDate")) = True Then
SummaryActualReqCompl = rstTeamDates("RequirementsCompleteDate")
Else
SummaryActualReqCompl = Null
End If
If IsDate(rstTeamDates("GroupSetupCompleteDate")) = True Then
SummaryActualGSU = rstTeamDates("GroupSetupCompleteDate")
Else
SummaryActualGSU = Null
End If
If IsDate(rstTeamDates("EnrollmentReceivedDate")) = True Then
SummaryActualEnrollRec = rstTeamDates("EnrollmentReceivedDate")
Else
SummaryActualEnrollRec = Null
End If
If IsDate(rstTeamDates("EnrollmentLoadedDate")) = True Then
SummaryActualEnrollLoaded = rstTeamDates("EnrollmentLoadedDate")
Else
SummaryActualEnrollLoaded = Null
End If
If IsDate(rstTeamDates("SPAASetupCompleteDate")) = True Then
SummaryActualSPAACompl = rstTeamDates("SPAASetupCompleteDate")
Else
SummaryActualSPAACompl = Null
End If
If IsDate(rstTeamDates("IDCardMeteredDate")) = True Then
SummaryActualIDCMetered = rstTeamDates("IDCardMeteredDate")
Else
SummaryActualIDCMetered = Null
End If
If IsDate(rstTeamDates("PlanLoadCompleteDate")) = True Then
SummaryActualPLNCompl = rstTeamDates("PlanLoadCompleteDate")
Else
SummaryActualPLNCompl = Null
End If
If IsDate(rstTeamDates("ProductBuildCompleteDate")) = True Then
SummaryActualPBDCompl = rstTeamDates("ProductBuildCompleteDate")
Else
SummaryActualPBDCompl = Null
End If
If IsDate(rstTeamDates("GroupBilledDate")) = True Then
SummaryActualBillReleased = rstTeamDates("GroupBilledDate")
Else
SummaryActualBillReleased = Null
End If
If IsDate(rstTeamDates("CertsIssuedDate")) = True Then
SummaryActualCertSPD = rstTeamDates("CertsIssuedDate")
Else
SummaryActualCertSPD = Null
End If
rstTeamDates.Close
Else
SummaryActualSoldNot = Null
SummaryActualReqCompl = Null
SummaryActualGSU = Null
SummaryActualEnrollRec = Null
SummaryActualEnrollLoaded = Null
SummaryActualSPAACompl = Null
SummaryActualIDCMetered = Null
SummaryActualPLNCompl = Null
SummaryActualPBDCompl = Null
SummaryActualBillReleased = Null
SummaryActualCertSPD = Null
rstTeamDates.Close
End If
If I run the Stored Procedure from an Access Pass Through query (exec sp_CombinedEventActualCycleTime 5713) In my code the EventProfileID is equal to 5713 as I step through the code.
Please show me the error of my ways!
Thanks, Troy