Skip to Content
avatar image
Former Member

Parameter prompt when exporting and/or Printing a report

With our reports there are usually a set of parameters that the user specifies at runtime and another set of parameters that are set in the background. I need to only prompt for the parameters that have not been set. When previewing the report in crystal reports viewer, it seems to be able to determine what has values and only prompt for the ones that don't. However, this doesn't seem to be the case when I prompt for the parameters when exporting or printing the report straight to the printer. This is what I'm using code-wise:

CrystalReportViewer viewer = new CrystalReportViewer();

viewer.ReportSource = rpt;

viewer.RefreshReport();

I can see using the HasCurrentValue parameter for each of the parameterFields that they do have values set but for some reason they are still shown on the prompt dialog. Is there anyway that I can hide these parameters?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Dec 16, 2016 at 06:33 AM

    Thanks for your reply, but I managed to get it working with setting

    crystalReportViewer1:ReuseParameterValuesOnRefresh = true;

    Though for some reason, it doesn't work with just that parameter, I needed to load the parameter count first by assigning something like

    paramcount = crystalReportViewer1:ParameterFieldInfo:count prior to running viewer.RefreshReport();

    Anyway, it's all good now! Thank you!

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 09, 2016 at 05:26 PM

    Unfortunately, there is no API to control the parameters screen when running reports. You would have to create your own parameter screen that would allow the user to specify values for the parameters that are not set in the background and then programmatically set those values on the report prior to viewing or exporting it.

    -Dell

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 24, 2017 at 04:33 PM

    I have this same problem. So far I've tried:

    Setting CRViewer1.ReuseParameterValuesOnRefresh = True at design time

    Setting CRViewer1.ReuseParameterValuesOnRefresh = True at runtime

    Calling Dim ParamCount As Integer = CRViewer1.ParameterFieldInfo.Count before calling CRViewer1.RefreshReport()

    Everything works fine on certain machines but not others. I can't pinpoint the difference. I've installed SP19 and it hasn't fixed the issue. I have other machines on SP18 that work properly. Does anyone have any other suggestions?

    Add comment
    10|10000 characters needed characters exceeded