I am trying to set a reports recordset to a record returning stored procedure with parameters
When I run the SP with these parameters it returns records but on the report no records are returned
This is the code that I am using
Code for ado Connection
When I run the SP with these parameters it returns records but on the report no records are returned
This is the code that I am using
Code:
Private Sub Report_Open(Cancel As Integer)
Dim StudentID As Integer
Dim ProviderID As Integer
Dim DisciplineId As Integer
Dim StartDate As Date
Dim EndDate As Date
Dim Frm As Form
Set Frm = Forms("FrmSelectCompleteSessionsParameters")
StudentID = Frm.StudentID
ProviderID = Frm.ProviderID
DisciplineId = Frm.DisciplineId
StartDate = Frm.StartDate
EndDate = Frm.EndDate
Set Me.Recordset = ExecuteAdoRS("SpSessionsUnionPrams", 4, 0, StudentID, ProviderID, DisciplineId, StartDate, EndDate)
End Sub
Code:
Public cnn As New ADODB.Connection
Dim cmd As New ADODB.Command
Function InitializeAdo()
If cnn.State = adStateClosed Then
cnn.ConnectionTimeout = 0
cnn.Open CurrentProject.Connection
End If
End Function
Function ExecuteAdoRS(AdoString As String, adoCommandType As Integer, ParamArray AdoPrams()) As ADODB.Recordset
'AdoPrams must have at least 1 value for the return value of a SP
Dim Prams As Integer
Dim a As Integer
InitializeAdo
cmd.CommandText = AdoString
Set cmd.ActiveConnection = cnn
cmd.CommandType = adoCommandType
cmd.CommandTimeout = 0
For Prams = 0 To UBound(AdoPrams)
cmd.Parameters.Item(Prams) = AdoPrams(Prams)
Next Prams
Set ExecuteAdoRS = cmd.Execute(a)
End Function