Click to See Complete Forum and Search --> : disable parameter prompt


jamie123
July 8th, 2008, 05:32 PM
I've been searching everywhere and testing different things but nothing seems to work so far. I'm using CR2008, standalone, I have one parameter which I set the "Optional Prompt" property to True. I declare the parameter in my vb.net code using the following:


Private Sub CrystalReportViewer1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles myCrystalReportViewer.Load
Me.FinancialTableAdapter.Fill(ds.Financial)
Dim rpt As New Report111
Dim crParameterDiscreteValue As ParameterDiscreteValue
Dim crParameterFieldDefinitions As ParameterFieldDefinitions
Dim crParameterFieldLocation As ParameterFieldDefinition
Dim crParameterValues As ParameterValues

crParameterFieldDefinitions = rpt.DataDefinition.ParameterFields

crParameterFieldLocation = crParameterFieldDefinitions.Item("intPID")
crParameterValues = crParameterFieldLocation.CurrentValues
crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
crParameterDiscreteValue.Value = Form1.intPID
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldLocation.ApplyCurrentValues(crParameterValues)

rpt.SetDataSource(ds)
Me.myCrystalReportViewer.ReportSource = rpt


I've tried setting "crParameterFieldLocation.HasCurrentValue = True"

But this gives me a "Property 'HasCurrentValue' is read-only."

Anyway on how to disable the prompts without using HasCurrentValue, or anyway to disable read-only on that property?

jggtz
July 9th, 2008, 12:34 AM
To turn off parameter prompting, set
ReuseReportParametersOnRefresh to false on the CrystalReportVeiwer control

jamie123
July 10th, 2008, 12:47 PM
It wont' let me use that, doesn't show up in intellisense

when I try this: myCrystalReportViewer.ReuseReportParametersOnRefresh = False


I get this: 'ReuseReportParametersOnRefresh' is not a member of 'CrystalDecisions.Windows.Forms.CrystalReportViewer'.



I have these imported: Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared

what else should I do?

edit: apparently the reusereportparametersonrefresh can only be used in web apps, http://forums.msdn.microsoft.com/en/vscrystalreports/thread/59254b69-56ec-4d64-8c61-2d74adec7af3/

jamie123
July 11th, 2008, 03:52 PM
Does really no one know? I was hoping this would be a simple question since I figured that most people do not use the ugly prompts in crystal reports, and have their parameters passed programmatically.

Here is all of my code, and what I have gotten done so far...The first entry,


Dim pVal As New CrystalDecisions.Shared.ParameterDiscreteValue
pVal.Value = Form1.intPID
Dim pField As New CrystalDecisions.Shared.ParameterField
pField.Name = "intPID" '<-- use the same parameter field name that you used in the report design
pField.CurrentValues.Add(pVal)
pField.HasCurrentValue = True

myCrystalReportViewer.ParameterFieldInfo.Clear() '<-- clears the one we created in design view
myCrystalReportViewer.ParameterFieldInfo.Add(pField) '<-- adds the one we created with code


does not prompt for the value, i continued to create more parameters the exact same way...


Dim pVal2 As New CrystalDecisions.Shared.ParameterDiscreteValue
pVal2.Value = lname
Dim pField2 As New CrystalDecisions.Shared.ParameterField
pField2.Name = "lname" '<-- use the same parameter field name that you used in the report design
pField2.CurrentValues.Add(pVal2)
pField2.HasCurrentValue = True


Dim pVal3 As New CrystalDecisions.Shared.ParameterDiscreteValue
pVal3.Value = fname
Dim pField3 As New CrystalDecisions.Shared.ParameterField
pField3.Name = "fname" '<-- use the same parameter field name that you used in the report design
pField3.CurrentValues.Add(pVal3)
pField3.HasCurrentValue = True

myCrystalReportViewer.ParameterFieldInfo.Add(pField2)
myCrystalReportViewer.ParameterFieldInfo.Add(pField3)



..but, they prompt for these parameters. intPID is used in a formula in the crystal report, the other parameters are simply just placed on the report itself, no formula depends on any of the parameters except for intPID

any help would be greatly appreciated, I just want to get rid of the ugly prompts for good, also, when I am in crystal reports 2008 and hit "edit" on the parameter, I made sure the other two parameters had the same properties as intPID, including "Optional Prompt - True"..the only difference between the two other parameters and intPID is that intPID is a number and the others are strings.

Thanks!

jamie123
July 14th, 2008, 11:59 AM
Found the answer out myself for all of those who are interested, the code above works for passing multiple parameters, however, I had it in the crystalreportviewer load event, I was debugging and noticed it loaded the report before it passed the parameters..so I put all that code in the form load event and now it works fine