I have a VB6 application that uses the RDC to automatically export a variety of reports as PDF files. Some of these reports get passed a department name as a parameter. Not all the departments apply to all the reports and in the cases where a report is passed a department that doesn't pertain to it, a blank report is created. The code below shows how it works.
What I want to do is check to see if a report returns any records before I go ahead and produce the PDF file and skip it in cases where the report is blank. I was thinking of some kind of test for records just before the line:
but I can't for the life of me figure out how to accomplish it. Can someone help?
Thanks in advance...
Code:
For i = 0 To UBound(strDepartments)
Set crxReport = crxApplication.OpenReport(strReportPath & strReportName)
crxReport.DiscardSavedData
Set crxParameterField = crxReport.ParameterFields.item(1)
crxParameterField.AddCurrentValue strDepartments(i)
With crxReport
If strServer <> "" Then
.Database.Tables(1).SetLogOnInfo strServer, strDatabase, strUID, strPassword
Set CrxSections = crxReport.Sections
For x = 1 To CrxSections.Count
Set CrxSection = CrxSections.item(x)
Set CrxReportObj = CrxSection.ReportObjects
For y = 1 To CrxReportObj.Count
If CrxReportObj.item(y).Kind = crSubreportObject Then
Set CrxSubreportObj = CrxReportObj.item(y)
Set CrxSubreport = CrxSubreportObj.OpenSubreport
Set CrxDatabase = CrxSubreport.Database
Set CrxDatabaseTables = CrxDatabase.Tables
Set CrxDatabaseTable = CrxDatabaseTables.item(1)
CrxDatabaseTable.SetLogOnInfo strServer, strDatabase, strUID, strPassword
End If
Next
Next
End If
.ExportOptions.DestinationType = crEDTDiskFile
.ExportOptions.DiskFileName = strExportPath & strDepartments(i) & " " & strExportName
.ExportOptions.FormatType = crEFTPortableDocFormat
.ExportOptions.PDFExportAllPages = True
.DisplayProgressDialog = False
.EnableParameterPrompting = False
.Export False
End With
Set crxParameterField = Nothing
Set crxReport = Nothing
Next
Code:
.Export False
Thanks in advance...