CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 5 of 5

Thread: disable parameter prompt

  1. #1
    Join Date
    Jun 2008

    disable parameter prompt

    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 code using the following:

    Private Sub CrystalReportViewer1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles myCrystalReportViewer.Load
    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

    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?

  2. #2
    Join Date
    Jul 2005

    Re: disable parameter prompt

    To turn off parameter prompting, set
    ReuseReportParametersOnRefresh to false on the CrystalReportVeiwer control

  3. #3
    Join Date
    Jun 2008

    Re: disable parameter prompt

    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,
    Last edited by jamie123; July 10th, 2008 at 11:57 AM.

  4. #4
    Join Date
    Jun 2008

    Re: disable parameter prompt

    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.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.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.HasCurrentValue = True

    ..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.


  5. #5
    Join Date
    Jun 2008

    Re: disable parameter prompt

    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 I put all that code in the form load event and now it works fine

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)