Results 1 to 2 of 2

Thread: [RESOLVED] RDLC Report with Multiple Subreports

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2012
    Location
    Minnesota
    Posts
    238

    Resolved [RESOLVED] RDLC Report with Multiple Subreports

    I have a main report with three subreports on it. My report worked fine when I just had one subreport on it so I think the problem is in my code for running the report.

    Below is my code for running the report and the subreport.
    Code:
     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim ReportViewer As New ReportView
            Dim ds As New WOReport
            Dim ta As New WOReportTableAdapters.DataTable1TableAdapter
            ta.FillByAllChecked(ds.DataTable1)
    
            ReportViewer.ReportViewer1.LocalReport.ReportPath = "c:\MaintenanceTracker\MaintenanceTracker\Reports\WOReportandSub.rdlc"
            ReportViewer.ReportViewer1.LocalReport.DataSources.Clear()
    
            Dim sReportDataSource As ReportDataSource
            sReportDataSource = New ReportDataSource()
            sReportDataSource.Name = "DataSet1"
            sReportDataSource.Value = ds.DataTable1
    
            AddHandler ReportViewer.ReportViewer1.LocalReport.SubreportProcessing, AddressOf SubreportProcessingEventHandler
            ReportViewer.ReportViewer1.LocalReport.DataSources.Add(sReportDataSource)
    
    
    
            ReportViewer.Show()
            ReportViewer.ReportViewer1.RefreshReport()
        End Sub
    
        Public Sub SubreportProcessingEventHandler(ByVal sender As Object, ByVal e As SubreportProcessingEventArgs)
            Try
                Dim ds As New WOLockOutSubReportDataSet
                Dim da As New WOLockOutSubReportDataSetTableAdapters.wolockTableAdapter
                Dim ds1 As New WOPartsSubReportDataSet
                Dim da1 As New WOPartsSubReportDataSetTableAdapters.wopartsTableAdapter
                Dim ds2 As New WOLaborSubReportDataSet
                Dim da2 As New WOLaborSubReportDataSetTableAdapters.wolaborTableAdapter
    
                da.Fill(ds.wolock)
                da1.Fill(ds1.woparts)
                da2.Fill(ds2.wolabor)
    
                e.DataSources.Add(New ReportDataSource("DataSet1", ds1.Tables("woparts")))
                e.DataSources.Add(New ReportDataSource("DataSet1", ds.Tables("wolock")))
                e.DataSources.Add(New ReportDataSource("DataSet1", ds2.Tables("wolabor")))
    
            Catch ex As Exception
                MessageBox.Show(ex.Message, My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Error)
            End Try
        End Sub
    Does anyone see where my problem is? I don't think I am loading the other two subreports properly. I thought I could just add them in like I did the first one.

    Thanks,
    Stacy

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Jun 2012
    Location
    Minnesota
    Posts
    238

    Re: RDLC Report with Multiple Subreports

    Got it solved.

    This is what I ended up with in case anyone else is trying to do this same thing.

    Public Sub SubreportProcessingEventHandler(ByVal sender As Object, ByVal e As SubreportProcessingEventArgs)
    Dim zrpt = e.ReportPath

    Select Case zrpt
    Case "WOPartsSubReport"
    Dim ds1 As New WOPartsSubReportDataSet
    Dim da1 As New WOPartsSubReportDataSetTableAdapters.wopartsTableAdapter
    da1.Fill(ds1.woparts)

    e.DataSources.Add(New ReportDataSource("DataSet1", ds1.Tables("woparts")))

    Case "WOLaborSubReport"
    Dim ds2 As New WOLaborSubReportDataSet
    Dim da2 As New WOLaborSubReportDataSetTableAdapters.wolaborTableAdapter
    da2.Fill(ds2.wolabor)

    e.DataSources.Add(New ReportDataSource("DataSet1", ds2.Tables("wolabor")))

    Case "WOLockoutSubReport"
    Dim ds As New WOLockOutSubReportDataSet
    Dim da As New WOLockOutSubReportDataSetTableAdapters.wolockTableAdapter
    da.Fill(ds.wolock)

    e.DataSources.Add(New ReportDataSource("DataSet1", ds.Tables("wolock")))

    End Select
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width