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

