Solved

Suppress Exporting Crystal Report as PDF IF No Data

Posted on 2007-12-06
4
1,504 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 250 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 250 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

623 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