Sunday, 16 December 2012

Disabling Parameter Prompt Dialog Box in Crystal Reports For Visual Studio

While working with Crystal Reports for Visual Studio 2010, I came across a strange problem. The problem was that the report was prompting me through a dialog box to input values for the parameters defined in the report when I was showing the report in my application. It was indeed a strange behavior as I had assigned the values to all the parameters in the report before showing the ReportViewer control.

I then started searching the internet for the solution to this problem, and came to know that users are experiencing this problem from as early as 2005!!! This made me wonder why this problem has not been resolved yet as I am using the very latest version (CR for VS 2010 Update 4) downloaded few days before from the SAP website. I came across many solutions that had been suggested to get rid of the dialog box.  I tried most of them but unsuccessfully as the obdurate dialog box refused to let go, and this made me really frustrated.

After spending many hours trying to find a fix to this issue, I finally got the solution posted in this blog post. The solution is to follow the steps provided below when showing a report:
  1. Assign a data source to the report like repotDocumentObject.SetDataSource(aDataSourceObject)
  2. Assign the report to the CrystalReportViewer control like reportViewer.ReportSource = reportDocumentObject.
  3. Set parameter values like reportDocumentObject.SetParameterValue(0, invoiceDate).
That's it. That is all required to get rid of the annoying Parameter Prompt  Dialog box in Crystal Reports for Visual Studio. 

7 comments:

  1. Thanks that really helped me

    ReplyDelete
  2. I just moved the SetParameterValue after the reportViewer.ReportSource statement, then it worked. Datasource setting is irrelevant to me. Thank you very much. You saved my day

    ReplyDelete
    Replies
    1. Man, you saved my life. As simple as that, and wouldn't ever imagine. Thank you!

      Delete
  3. It is super blog, I would like to be like you. Please Visit:

    cafe pos
    retail system
    pos cash register

    ReplyDelete
  4. Hi, I tried to follow your instruction however the parameter prompt still showing up. Please my code below.

    Private Sub CRViewReport()

    Dim strCRReportName = "CheckOut.rpt"
    Dim rpt As New ReportDocument

    rpt.Load(Application.StartupPath & "\Reports\" & strCRReportName)

    frmcrv.CrystalReportViewer1.ReportSource = rpt
    rpt.SetParameterValue("ParamCheckID", 15)

    frmcrv.Show()

    End Sub

    By the way, I use command query in the Crystal report. All i need is to pass a parameter to crystal report.

    Thanks in advance.

    ReplyDelete