Wednesday, March 7, 2012

Missing parameter values error

I am using a CR viewer in VS 2005 (VB 2005). I am using the ReportDocument class to print the report. I get a "Missing parameter values" error when the code gets to the "PrintToPrinter" method. Here's my code:

Dim rpt2 As New CrystalDecisions.CrystalReports.Engine.ReportDocument

Dim param1Fields As New CrystalDecisions.Shared.ParameterFields

Dim param1Field As New CrystalDecisions.Shared.ParameterField()

Dim param1Range As New CrystalDecisions.Shared.ParameterDiscreteValue()

param1Field.ParameterFieldName = "CaseIDin" ' Parameter Name In Crystal Report

param1Range.Value = strCaseID.ToString ' value For Parameter Field

param1Field.CurrentValues.Add(param1Range)

param1Fields.Add(param1Field) ' To add parameter in parameterslist

rpt2.Load("C:\CaseHistory.rpt")

rpt2.DataDefinition.ParameterFields("CaseIDin").CurrentValues.Clear()

rpt2.DataDefinition.ParameterFields("CaseIDin").CurrentValues.Add(param1Range)

rpt2.PrintToPrinter(1, False, 0, 0)

What's wrong with this code? How do I get the parameters correct.

TIA,

SteveOne of the parameters is not given value. Make sure you supplied values for all the parameters

No comments:

Post a Comment