Quantcast
Viewing all articles
Browse latest Browse all 3636

IsOptionalPrompt property value incorrect on parameter

We have the following subroutine in our vb.net app that will preview a report, but are having a problem with it not retaining all of the parameter properties, specifically, the "IsOptionalPrompt".  The report has been loaded into the objReportDocument object (that has been set to the CrystalDecisions.CrystalReports.Engine.ReportDocument object model) via the LoadReport() method.  The report we are working with had 4 parameters, the last two of which are optional (IsOptionalPrompt = True).

 

When the vb.net code is executed below, the IsOptionalPrompt = True in the objReportDocument parameter properties for these last two parameters, but when the RefreshReport() is executed, the parameter setting in the report viewer has the IsOptionalPrompt = False.  As a result, it sets our variable, blnInputParmsSet = False, and does not run the report (once it exits this subroutine, we have other code to only run the report if blnInputParmsSet = True). 

 

We need the ReportViewer parameter screen to pop up so the user can enter the parameter values for the report.  The RefreshReport() method brings up the parameter screen just fine, but it appears setting the viewer.reportsource is not retaining the objreportdocument properties (for parameters).  Is this correct?

 

If I manually add a line of code, objViewer.ParameterFieldInfo(i).IsOptionalPrompt = objReportDocument.ParameterFields(i).IsOptionalPrompt, after the For i = 0 To objViewer.ParameterFieldInfo.Count - 1, the property is correct.  I can do this, but then what other properties do I need to set?

Moreover, why does the RefreshReport() clear these values?

 

Thank you

 

 

 

 

Sub SetReportInputParmsFromViewer()

Dim i AsInteger


'For Custom Reports

'Must Use the ReportViewer because objReportDocument will not automatically

'prompt for parameters if no parameters passed in.

        objViewer.ReportSource = objReportDocument

objViewer.RefreshReport()

 

'Does this report have parameters?

'If so, then check to see if the parameter is required to have a value

If objViewer.ParameterFieldInfo.Count > 0 Then


For i = 0 To objViewer.ParameterFieldInfo.Count - 1


'If a value is optional, then set blnInputParmsSet to true

'If value is required, then check to see if it has a value.

'If not, set the blnInputParmsSet to false

 

If objViewer.ParameterFieldInfo(i).IsOptionalPrompt = FalseAnd _

  objViewer.ParameterFieldInfo(i).HasCurrentValue = False Then

   blnInputParmsSet = False

   Exit For

End If

 

Next


End
Sub


Viewing all articles
Browse latest Browse all 3636

Trending Articles