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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check for records in report before exporting?

Status
Not open for further replies.

jbradley

Programmer
Sep 7, 2001
248
US
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.
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 <> &quot;&quot; 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) & &quot; &quot; & strExportName
        .ExportOptions.FormatType = crEFTPortableDocFormat
        .ExportOptions.PDFExportAllPages = True
        .DisplayProgressDialog = False
        .EnableParameterPrompting = False
        .Export False
    End With
    Set crxParameterField = Nothing
    Set crxReport = Nothing
Next
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:
Code:
        .Export False
but I can't for the life of me figure out how to accomplish it. Can someone help?

Thanks in advance...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top