Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Suppress Exporting Crystal Report as PDF IF No Data

Posted on 2007-12-06
4
Medium Priority
?
1,514 Views
Last Modified: 2008-02-01
Hello,

I batch export several Crystal Reports as PDF using a VB.NET 2003 Windows application.  However, since I am exporting to PDF and not printing, I cannot suppress if there are no records anymore.  The property the report has to suppress printing if no data doesn't apply to exporting as PDF.  Therefore,  I end up with several PDFs that are blank because they did not have any records.

I'm using the ReportDocument (CR)  class and the CR.ExportOptions process to export.  Here's a sample of what I do after the report is ready to be exported.

Dim CR as New  ReportDocument
..
..' provide path to open the report and enter parameters here too.

With CrExportOptions
        ' Set the destination to a disk file
      .ExportDestinationType = ExportDestinationType.DiskFile
      ' Set the format to PDF
      .ExportFormatType = ExportFormatType.PortableDocFormat
      ' Set the destination options to DiskFileDestinationOptions object
      .DestinationOptions = CrDiskFileDestinationOptions
      .FormatOptions = CrFormatTypeOptions
End With
' Export the report to the PDF folder path
CR.Export()

Is there a way to stop the exporting process if the report is blank or has no records?   I was hoping to use something like size property, but I can't find it.

Any help would be tremendously appreciate it.
0
Comment
Question by:TheUndecider
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 4

Accepted Solution

by:
habibb earned 1000 total points
ID: 20426907
if you can check the datasource of report if its empty mean no records then you can stop exporting to pdf.
if its not possible for you to directly check datasource for example Dataset then you can get dataset from report document object and see if it  has data then proceed for pdf otherwise stop exporting to pdf.
0
 
LVL 101

Assisted Solution

by:mlmcc
mlmcc earned 1000 total points
ID: 20432724
There is a report property you can check but you must "display" the report then xport it.

I did this when we were displaying reports and tested the record count before making the viewer visible.  If there were no records then I simply displayed that message rather than showing a report.

This will increase processing time since the report is rendered twice.  Once for the hidden display then again for the export.

mlmcc
0
 
LVL 1

Expert Comment

by:Computer101
ID: 20592627
Forced accept.

Computer101
EE Admin
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question