SAP Knowledge Base Article - Public

1496220 - Suppress the default parameter prompt when the parameter value is not passed through the code

Symptom

  • A default parameter prompt appears showing the default values, when either null or no values are passed from the code.

Environment

  • Visual Studio 2003 / Visual Studio 2005
  • Crystal Reports XI / Crystal Reports XI R2

Reproducing the Issue

  • Create a Crystal report containing date parameters, each having single default value.
  • Create a custom application using CR SDK for VS .NET to pass the parameter values and view the report.
  • Pass a NULL or no parameter values through the code to the report
  • A default value prompt displays showing the default values and  prompting to enter the values.

Resolution

  • To solve this problem and to supress the default value prompt, the default values should be passed to the report as current values.
  • Following code passes the default values as current values to the report when no current values are passed to the report through code.
Dim crDefaultValues As New ParameterValues 
Dim crCurrentValues As New ParameterValues
Dim crValue As ParameterValue

'Create an instance of the strongly-typed report object 
crReportDocument.Load(Server.MapPath("MyCrystalReport.rpt"))

'The viewer's reportsource must be set to a report before any parameter fields can be accessed. 
crReportDocument.Refresh()

'Get the collection of parameters from the report 
crDefaultValues = crReportDocument.ParameterFields("DateParameterName1").DefaultValues
crCurrentValues = crReportDocument.ParameterFields("DateParameterName1").CurrentValues

' Loop through each value in the DefaultValues collection. Add each value to the CurrentValues. 
For Each crValue In crDefaultValues
 crCurrentValues.Add(crValue)
Next
 crDefaultValues = crReportDocument.ParameterFields("DateParameterName2").DefaultValues
 crCurrentValues = crReportDocument.ParameterFields("DateParameterName2").CurrentValues

' Loop through each value in the DefaultValues collection. Add each value to the CurrentValues. 
 For Each crValue In crDefaultValues
 crCurrentValues.Add(crValue)
Next

'Set the reportsource to the viewer. 
CrystalReportViewer1.ReportSource = crReportDocument End Sub


End Sub

Keywords

Default parameter prompt, suppress parameter prompt, parameter , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem

Product

SAP Crystal Reports XI