Crystal Report Parameter Prompt Suppressing

I'm using Crystal Reports in VB 2005. I had the same problem with trying to suppress the parameter prompting. I installed the patch that was mentioned in this tread and it didn't help. This is how I got mine to work:

1) Using the crystal designer in vs 2005, create your parameters and place them on your report. Let’s just say you created a parameter called 'TitlePage' in a report called 'InventoryDetails'.

2) In your code, just before you’re ready to display the 'InventoryDetails' report, create a new parameter with the same name as the one you used in your report designer (TitlePage). To do this, do the following:

' Setup the parameter field and value for the report
Dim pValAs NewCrystalDecisions.Shared.ParameterDiscreteValue
pVal.Value = Me.txtMyTitle.Text
<-- Set the parameter value
Dim pFieldAs NewCrystalDecisions.Shared.ParameterField<-- Create a new parameter field to hold the value.
pField.Name = "TitlePage"
'<-- Use the same parameter field name that you used in the report design.
pField.CurrentValues.Add(pVal)<-- Add the value to the field.
pField.HasCurrentValue =
True<-- This tells the parameter not to prompt because it already has a value.

3) Now you will need to replace the parameter you created in design view with the one you just created in code on the report viewer.

' Setup the report viewer and show the report to the user
DimpReportViewerAs NewfrmReportViewer<-- Create a new instance of your report viewer.
pReportViewer.FMS_CrystalReportViewer.ReportSource = InventoryDetails
<-- set the report source to your report
pReportViewer.FMS_CrystalReportViewer.ParameterFieldInfo.Clear()
'<-- clear the parameter we created in design view
pReportViewer.FMS_CrystalReportViewer.ParameterFieldInfo.Add(pField)'<-- add the parameter we created with code
pReportViewer.Show()
<-- Shows the report with the parameter populated with txtMyTitle.text without prompting for it.

As you can tell, this is VB and not C# but regardless of the language they use the same objects. This worked for me when nothing else would and I hope it can help some of you guys.

-Tim

[4328 byte] By [TimSexton] at [2008-1-7]
# 1

Exactly this is my C# conversion and works very Well!!

Code Snippet

///Parameter Field

ParameterDiscreteValue val = new ParameterDiscreteValue();

val.Value = "Utente di test.";

ParameterField fld = new ParameterField();

fld.Name = "ID_User";

fld.CurrentValues.Add(val);

fld.HasCurrentValue = true;

///View it!

this.crystalReportViewer1.ReportSource = rpt;

this.crystalReportViewer1.ParameterFieldInfo.Clear();

this.crystalReportViewer1.ParameterFieldInfo.Add(fld);

this.crystalReportViewer1.Show();

So, thanks Tim.

raffaeu_ugi at 2007-10-2 > top of Msdn Tech,Visual Studio,Crystal Reports for Visual Studio...
# 2
I did it even shorter in C#.
Put this code in your crystal report viewr_Load

ReportName extReport = new ReportName();
extReport.SetParameterValue(0, extendedID);
crystalReportViewer3.ReportSource = extReport;

and that is it.

sof at 2007-10-2 > top of Msdn Tech,Visual Studio,Crystal Reports for Visual Studio...

Visual Studio

Site Classified