cancel
Showing results for 
Search instead for 
Did you mean: 

Crystal Report Windows Forms Viewer - No Error Popup

0 Kudos

Similar to this post:  works fine the first time a report is loaded, but when I change the parameters on the report, and put the updated report back into the report viewer, I get the message shown above.  The report does not change its parameters and the updated report is not displayed.  The code in question is setting the date parameters for the report.  The user can select new date parameters from the form that encloses the report viewer.  The code subclasses the Report Object code to add additional functions through interfaces.  The IDateRange interface provides a starting and ending date range for the report using a property on the report class as follows:

    Public Property EndingDate() As Date Implements IDateRange.EndingDate

        Get

            Return _endingDate

        End Get

        Set(ByVal value As Date)

            _endingDate = value

            Me.SetParameterValue("EndingDate", value)

        End Set

    End Property

In addition, the immediate Window shows the following message:

A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in CrystalDecisions.CrystalReports.Engine.dll

The code in the Report Viewer looks like this, see line marked in blue for when pop-up appears:

''' <summary>
''' Sets the report period and displays it.
''' </summary>
''' <param name="Report">The Report.</param>
''' <param name="Refresh">if set to <c>true</c> force a refresh.</param>
Private Function PFSetReportPeriod(ByVal Report As Object, Optional ByVal Refresh As Boolean = True) As Boolean
    Dim fld As FormulaFieldDefinition
    Dim bRefresh As Boolean = False
    Dim rpt As ReportClass = CType(Report, ReportClass)
    Try
        If CRV.ReportSource IsNot Nothing Then
            rpt = CType(CRV.ReportSource, ReportClass)
        End If

If TypeOf rpt Is IDateRange Then
    With DirectCast(rpt, IDateRange)
.        StartingDate = dtpFromDate.Value
.        EndingDate = dtpToDate.Value
    End With
    SetTitleLine2(DirectCast(Report, ReportClass), bRefresh)
    bRefresh = True
Else
    If TypeOf rpt Is ReportClass Then
       fld = rpt.DataDefinition.FormulaFields("FromDate")
       If Not fld Is Nothing Then
            fld.Text = "Date(" & dtpFromDate.Value.Year & "," & dtpFromDate.Value.Month & "," & dtpFromDate.Value.Day & ")"
            bRefresh = True
        End If
        fld = rpt.DataDefinition.FormulaFields("ToDate")
        If Not fld Is Nothing Then
            fld.Text = "Date(" & dtpToDate.Value.Year & "," & dtpToDate.Value.Month & "," & dtpToDate.Value.Day & ")"
            bRefresh = True
        End If
        SetTitleLine2(rpt, bRefresh)
    End If
End If

    If Refresh And bRefresh Then
        If dtpToDate.Value <> CDate(dtpToDate.Tag) OrElse _
           dtpFromDate.Value <> CDate(dtpFromDate.Tag) Then
                System.Windows.Forms.Application.DoEvents()
            If CRV.Visible Then CRV.ReportSource = rpt ' The popup appears when this statement is executed.
            If CRV.Visible = True Then CRV.Refresh()
            dtpToDate.Tag = dtpToDate.Value
            dtpFromDate.Tag = dtpFromDate.Value
           Return True
        End If
    End If
Catch ex As Exception
    DisplayException(ex)
End Try
Return False

End Function

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Problem has been resolved.  I downloaded Support Pack 8 (v.13.0.8.1216) from this location.  I then applied the fix from the entry above:

               With CRV ' Report Viewer Control
                        If .Visible Then
                                If .ParameterFieldInfo IsNot Nothing Then .ParameterFieldInfo.Clear()
                                .ReportSource = rpt
                                .Refresh()
                        End If
                End With

And no more annoying "No Error" messages.

Answers (1)

Answers (1)

0 Kudos

Just tried technique from this site - with no result - I still get the pop-up window.

Crystal Report not refreshing based on parameter values in asp.net - ASP.NET,C#.NET,VB.NET,JQuery,Ja...