We help IT Professionals succeed at work.

Crystal reports update parameter

FCapo
FCapo asked
on
128 Views
Last Modified: 2015-11-18
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

Comment
Watch Question

Mike McCrackenSenior Consultant
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2013

Commented:
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

Author

Commented:
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"
Senior Consultant
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2013
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.