Avatar of FCapo
FCapo
 asked on

Crystal reports update parameter

Hi,

I have a crystalreportviewer on my form, I'd like to from a button on the form be able to update my report with a new parameter value once the report is already loaded, is there a way to change the parameter value in realtime through code, such as if I were to press the refresh button?

    
    Dim param1Fileds As New CrystalDecisions.Shared.ParameterFields
        Dim param1Field As New CrystalDecisions.Shared.ParameterField
        Dim param1Range As New CrystalDecisions.Shared.ParameterDiscreteValue

        param1Field.ParameterFieldName = "emp"
        param1Range.Value = "Phil" ' value For Parameter Field 
        param1Field.CurrentValues.Add(param1Range)
        param1Fileds.Add(param1Field)
        CrystalReportViewer1.ParameterFieldInfo = param1Fileds 'to pass parameter inf.to CRV
        CrystalReportViewer1.Refresh()

        Dim param1Fileds1 As New CrystalDecisions.Shared.ParameterFields
        Dim param1Field1 As New CrystalDecisions.Shared.ParameterField
        Dim param1Range1 As New CrystalDecisions.Shared.ParameterDiscreteValue

        param1Field1.ParameterFieldName = "emp"
        param1Range1.Value = "Carl" ' value For Parameter Field 
        param1Field1.CurrentValues.Add(param1Range1)
        param1Fileds1.Add(param1Field1)
        CrystalReportViewer1.ParameterFieldInfo = param1Fileds1 'to pass parameter inf.to CRV
        CrystalReportViewer1.Refresh()

Open in new window

Crystal Reports.NET Programming

Avatar of undefined
Last Comment
Mike McCracken

8/22/2022 - Mon
Mike McCracken

You should be able to do that.  The button won't be part of the viewer.

What is wrong with the refresh button.

Your button should just rerun the code that loads the report and prompts for the parameters.

mlmcc
FCapo

ASKER
I'd like to update the  parameter : param1Field1.ParameterFieldName = "emp"
to a different employee name by a button on the form, but it stays stuck on the first value i gave it "Phil"
ASKER CERTIFIED SOLUTION
Mike McCracken

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes