Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How Do I Set a Reports Recordset

Status
Not open for further replies.

PWise

Programmer
Dec 12, 2002
2,633
US
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:
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 for ado Connection
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

 
What version of Access?

I don't think Access supports setting a recordset in a Report, although it does in a Form. Maybe the latest versions it does.
 
i am using access 2003

well this works
Code:
Dim add As ADODB.Command
Set add = New ADODB.Command
add.ActiveConnection = CurrentProject.Connection
add.CommandText = "select * from students"
Set Me.Recordset = add.Execute
so settng recordsets forreports works in this version of Access?
 
update the code from my first post works if i dont add any group headers

so my new question is

How do I set a reports recordset when I have group headers



 
I found this on on Microsoft

i downloaded the file adoacc02.exe

see pages 18 - 23 in the word doc

i created a flat table grouped report

got the reports shape
?Reports("reportsname").Shape
put this code in the report open

Code:
Dim cnn As ADODB.Connection
Dim rst As ADODB.Command
Set cnn = New ADODB.Connection
Set rst = New ADODB.Command
cnn.ConnectionString = "Provider=msdatashape;Persist Security Info=False;Data Source=SERVER;Integrated Security=SSPI;Initial Catalog=TempConvert;Data Provider=SQLOLEDB.1"
cnn.Open
rst.ActiveConnection = cnn
rst.CommandText = "SHAPE (SHAPE (SHAPE {SELECT Sessions.* FROM Sessions} AS rsLevel0 COMPUTE rsLevel0 BY StudentId AS __COLRef0, ProviderId AS __COLRef1) AS rsLevel1 COMPUTE rsLevel1, Sum(rsLevel1.rsLevel0.[Sessions]) AS __Agg0 BY __COLRef0) AS RS_86"
Set Me.Recordset = rst.Execute

[/code}

the code runs no errors but access crashes 
any one out ther to help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top