- Suppress Printing If No Records option is turned on.
- PrintToPrinter() method is called in a Crystal Reports .NET application.
- A blank page is printed by the printer.
- No page should be printed as set in the Report Options.
- Microsoft Visual Studio
- Crystal Reports .NET SDK
- Crystal Reports XI R2
- Crystal Reports 2008
Reproducing the Issue
- Open a Crystal Report in the Crystal Reports designer.
- Go to File > Report Options ...
- Make sure Suppress Printing If No Records is selected.
- Click OK.
- Use this report in a custom application with the Crystal Reports .NET SDK.
- Run the report in the application such that there are no records returned.
- Use the PrintToPrinter() method to print the report.
- A blank report will be printed.
The issue has been identified and logged under Problem Report ID ADAPT00264642.
There are few work arounds as follows:
- Check a field that will be some particular value if and only if the report has no data (e.g.; some field is NULL). If the field is NULL don't enter the print function.
- Another way may be to retrieve the SQL query that returned the data and check that your self to see if number of records returned is zero. This may not work if there is any client side processing being done by the report.
- ReportDocument has a property called Rows which can also help to get the count. See the code below
If objReport.Rows.Count > 0 Then
objReport.PrintToPrinter(1, False, 0, 0)
- There is the rowset controller with InProc RAS. Note that InProc RAS is not available in the versions of CR that bundle with .NET and only available with CR XI R2 or 2008. See the code below:
Dim crReportClientDoc As ClientDoc.ReportClientDocument
Dim crRowsetController As Controllers.RowsetController
Dim crRowsetCursor As Controllers.RowsetCursor
crReportClientDoc = New ClientDoc.ReportClientDocument
crReportClientDoc.ReportAppServer = "127.0.0.1"
crRowsetController = crReportClientDoc.RowsetController
crRowsetCursor = crRowsetController.CreateCursor(Nothing)
Me.TextBox1.Text = crRowsetCursor.RecordCount
- The issue is resolved in SAP Crystal Reports 2013
- The issue is also resolved in SAP Crystal Reports, developer version for Microsoft Visual Studio, Service Pack 7
Suppress Printing if no records, Crystal Reports, XI R2, 2008, .NET SDK, Visaul Studio , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem