Please could someone help me on this. I have a button on which when clicked will display the crystal report. This report displays as required but when I want to view the report the second time, there's this error message: "Index 0 is out of range, Parameter name:index". FYI - The user just selects the date from the DateTime Picker control and clicks the OK button and the report should be display. The report is generated from a view in SQL Server 2008 Database. The code behind the OK button is:

Private Sub btnOK1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK1.Click
        'Summary of calls for any given date.
        'Dim objReport As New DALReport
            Dim cr As New rptCallSummaryGivenDate
            Dim frm As New frmReporting1
            Dim str As String
            str = CType(dtpSpecificDateCalls.Text, Date).ToString("yyyy-MM-dd")

            'Parameter to call the report

            'Cheeck whether the data exists for this date for reporting
            If objReport.dss.Tables("vw_CallTally").Rows.Count > 0 Then
                'For the report form
                frm.SDCR_CrystalReportViewer.ReportSource = cr
                frm.MdiParent = Me.MdiParent
                frm.Text = "Call Summary for " & str
                frm.MaximizeBox = True
                frm.WindowState = FormWindowState.Maximized
                If MessageBox.Show("There's no data available associated with this date for reporting", "No Data", MessageBoxButtons.OK, MessageBoxIcon.Information) = Windows.Forms.DialogResult.OK Then
                End If
            End If
        Catch ex As Exception
        End Try
    End Sub

Edited 5 Years Ago by kipslem: n/a

Hello Everyone,

I managed to solve the Problem, so never mind. For newbie programmers incase you might have similar issues, here's the solution: I was declaring the frmReporting1 and str as a public variable (outside of the OK Click event) and have that name applied to other click events for similar reporting. So I just have that declared withing each of the click events for/to display the different report. So DECLARE THE VARIABLES WITHIN EACH CLICK EVENT INSTEAD OF THE GLOBAL.


This question has already been answered. Start a new discussion instead.