Hello,

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
        Try
            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
            objReport.LaodCallSummaryReport(str)

            'Cheeck whether the data exists for this date for reporting
            If objReport.dss.Tables("vw_CallTally").Rows.Count > 0 Then
                cr.SetDataSource(objReport.dss.Tables("vw_CallTally"))
                '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
                frm.Show()
            Else
                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
            MessageBox.Show(ex.Message)
        End Try
    End Sub

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.

Thanks,
kipslem

Hello Everyone,

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.