I have created a report in Crystal Report 9 with a single date parameter. I call this report in some VB 6 code (below). The problem I have is that an empty report is printed each time I run the code with a valid date. (Running the stored procedure independently with a valid date always returns records). I do not seem to be linking my recordsource (an SQL stored procedure apsp_srptDispensation) to my report and a blank report is printed each time. (i.e headers are printed and no detail records).
All suggestions appreciated.
The VB 6 code is:
Dim crCrystal As CRAXDRT.Application 'loads report from file
Dim crReport As CRAXDRT.Report 'holds report
Dim strError As String
Dim avarparameters(1, 5)
Dim rst As adodb.Recordset
' 1. Run stored procedure to get report data
' set the date parameter
'
avarparameters(0, 1) = "Run Date" 'Name
avarparameters(0, 2) = adDate ' Data type
avarparameters(0, 3) = 8 ' size
avarparameters(0, 4) = adParamInput 'direction
avarparameters(0, 5) = datLastRunDate 'value
Set rst = ExecuteSP_ADOrst("apsp_srptDispensation", "ISD_DVL1", "ADESPS", avarparameters())
If rst.EOF Then
MsgBox "No records have met the selection criteria for the Dispensation Report"
rst.Close
GoTo DispensationsReport_EXit
End If
Set crCrystal = New CRAXDRT.Application 'manages reports
Set crReport = crCrystal.OpenReport("c:\crystal parking reports\rptDispensationADHOC.rpt") 'open report
' Make sure the user isn't asked for the parameter values
crReport.EnableParameterPrompting = False
crReport.DiscardSavedData 'clears report so we can work from the recordset
crReport.Database.SetDataSource rst 'link report to recordset
crReport.PrintOut ' print the report
'Once the report is displayed, we can then cleanup out objects:
rst.Close 'ALL BELOW HERE IS CLEANUP
Set rst = Nothing
Set crCrystal = Nothing
Set crReport = Nothing
DispensationsReport_EXit:
Exit Function
All suggestions appreciated.
The VB 6 code is:
Dim crCrystal As CRAXDRT.Application 'loads report from file
Dim crReport As CRAXDRT.Report 'holds report
Dim strError As String
Dim avarparameters(1, 5)
Dim rst As adodb.Recordset
' 1. Run stored procedure to get report data
' set the date parameter
'
avarparameters(0, 1) = "Run Date" 'Name
avarparameters(0, 2) = adDate ' Data type
avarparameters(0, 3) = 8 ' size
avarparameters(0, 4) = adParamInput 'direction
avarparameters(0, 5) = datLastRunDate 'value
Set rst = ExecuteSP_ADOrst("apsp_srptDispensation", "ISD_DVL1", "ADESPS", avarparameters())
If rst.EOF Then
MsgBox "No records have met the selection criteria for the Dispensation Report"
rst.Close
GoTo DispensationsReport_EXit
End If
Set crCrystal = New CRAXDRT.Application 'manages reports
Set crReport = crCrystal.OpenReport("c:\crystal parking reports\rptDispensationADHOC.rpt") 'open report
' Make sure the user isn't asked for the parameter values
crReport.EnableParameterPrompting = False
crReport.DiscardSavedData 'clears report so we can work from the recordset
crReport.Database.SetDataSource rst 'link report to recordset
crReport.PrintOut ' print the report
'Once the report is displayed, we can then cleanup out objects:
rst.Close 'ALL BELOW HERE IS CLEANUP
Set rst = Nothing
Set crCrystal = Nothing
Set crReport = Nothing
DispensationsReport_EXit:
Exit Function