Quantcast
Viewing all articles
Browse latest Browse all 3636

CrystalReportViewer Refresh

I am using Visual Studio 2008 with  Crystal Reports 2008 SP3 for a winforms project.  The issue I have is  that when I launch a report using the CrystalReportViewer control and  the user clicks on the Refresh button on the viewer, a dialog pops up  asking for parameters.  I have flagged the CrystalReportViewer control  to ReuseParameterValuesOnRefresh and EnableRefresh.

 

My users need to be able to refresh the report to see  changes made in the underlying database.

 

 

The method used to launch the preview follow:

 

   Public Sub PreviewReport(ByVal ReportPath As String, ByVal ORDERID As Integer)

        Dim rptv As New frmPreview

        Dim Report As New ReportDocument

        Dim pv As New ParameterValues

        Dim pdv As ParameterDiscreteValue

 

        Try

            pdv = New ParameterDiscreteValue

            pdv.Value = ORDERID

            pv.Add(pdv)

            Report.Load(ReportPath)

            Report.PrintOptions.PrinterName = ""

            Report.SetParameterValue("ORDERID", pv)

            rptv.Preview(Report)

        Catch Ex As Exception

            MsgBox("Error generating report.  Error: " & Ex.Message, MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, "Error")

        End Try

    End Sub

 

frmPreview  is a simple Windows.Form with a CrystalReportViewer on it and not  special handling.  The Preview method of the form follows:

 

Private myReport As ReportDocument

 

Public Sub Preview(ByVal rpt As ReportDocument)

        myReport = rpt

        crv1.EnableRefresh = True

        crv1.ReuseParameterValuesOnRefresh = True

        Me.Show()

        rpt.PrintOptions.PrinterName = ""

        Me.crv1.ReportSource = rpt

        crv1.Show()

End Sub


Viewing all articles
Browse latest Browse all 3636

Trending Articles