Symptom
- The parameter prompt screen is invoked by the Crystal Reports viewer.
- When printing a report directly without displaying the viewer, the parameter prompt is not invoked.
Environment
- SAP Crystal Reports, Developer Version for Visual Studio .NET
- Microsoft Visual Studio .NET 2010 / 2012 / 2013.
Reproducing the Issue
- Using the following code will not invoke the parameter prompt:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ReportDocument1 As New CrystalDecisions.CrystalReports.Engine.ReportDocument
ReportDocument1.Load("C:\WindowsApplication7\test.rpt")
ReportDocument.PrintToPrinter(1, True, 1, 1)
End Sub
Cause
- As the Crystal Reports viewer is not used, the parameter prompt is not invoked.
Resolution
- Add a viewer to the project.
- Set the "Doc" property to none.
- Set the viewer property DisplayStatusBar to False.
- Shrink the viewer so it only displays the print button on the viewer manu bar.
- In the simples project, the code to sue would be:
Dim crReportDocument As New CrystalDecisions.CrystalReports.Engine.ReportDocument
crReportDocument.Load(<path to the report with parameter prompt>)
CrystalReportViewer1.ReportSource = crReportDocument
CrystalreportViewer1.ReportSource = crReportDocument
6. Run the project. The project should prompt for database login - if needed and for the parameters the report needs.
A screenshot of the project:
Note that in the above project the viewer was shrunk so that the export, refresh and print buttons would be visible. The viewer can be further shrunk to only show the print button.
- The only other solution is to create your own parameter prompt screen, capture the user input and pass that to the report.
- For parameter API details see the SAP Crystal Reports .NET SDK Developer Guide and SAP Crystal Reports .NET API Guide.
Keywords
cr crvs param 2010 2012 2013 asp .net app applicatioin , KBA , BI-DEV-NET-SDK , .NET SDK / COM SDK , How To