Results 1 to 6 of 6

Thread: [RESOLVED] VS2010 RDLC Local Report with SubReport

Threaded View

  1. #1

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

    Resolved [RESOLVED] VS2010 RDLC Local Report with SubReport

    I am trying to make an rdlc report with a subreport. Both reports are using their own dataset.

    I have made my parent RDLC report, WOReportandSub.rdlc, and it works fine. I have a list and several textbox's placed on it. It is grouped on WONum.

    I then made my subreport, WOLockOutSubReport.rdlc, on which I placed one table and selected fields from my dataset. I added a parameter to the report called WONum - integer.

    Then back to the main report I placed a subReport from the toolbox and then right clicked on it and went to Subreport properties and typed in the name of my subreport exactly as it is in the project minus the .rdlc part. Visibility is set to Show. I added a Parameter called WONum and chose the value for it as my [WONum] column from my dataset. If I run just the subreport by itself I get an error that says WONum parameter is missing a value, which would be true since I didn't pass it a parameter and the Main Report didn't pass it one because I ran it by itself. So I guess I'm wondering how I get that main report to pass the variable to the subreport.

    I have a winform with all my report buttons and the code to run this report is as follows:

    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
            ReportViewer.ReportViewer1.LocalReport.DataSources.Add(sReportDataSource)
    
            AddHandler ReportViewer.ReportViewer1.LocalReport.SubreportProcessing, AddressOf Me.SubreportProcessingEventHandler
    
            ReportViewer.Show()
            ReportViewer.ReportViewer1.RefreshReport()
        End Sub
    The code for the subreportProcessing is as follows:
    Code:
     Public Sub SubreportProcessingEventHandler(ByVal sender As Object, ByVal e As SubreportProcessingEventArgs)
            Try
                Dim ds As New WOLockOutSubReportDataSet
                Dim da As New WOLockOutSubReportDataSetTableAdapters.wolockTableAdapter
    
                da.Fill(ds.wolock, e.Parameters("WONum").Values(0))
    
                e.DataSources.Add(New ReportDataSource("DataSet1", ds.Tables("wolock")))
            Catch ex As Exception
                MessageBox.Show(ex.Message, My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Error)
            End Try
        End Sub
    The error I get when I try to run the report is "An error occurred during local report processing. Value cannot be null. Parameter name: value." I'm not sure what this means because I don't have a parameter called value it's called WONum.
    Anyway I'm sure the error is probably in this code to actually run the report, but I can't seem to figure out what is wrong. I don't pass a parameter to the Main RDLC - the fill query for the dataset is any records that have the PrintStatus column = 1. So it could be bringing up several WONum's. The query for the subreport's dataset fill is bringing up the data for the same WONum's.

    Does anyone know what I'm doing wrong. I have been working on this for days and I would really appreciate any input
    Thanks,
    Stacy
    Last edited by StacyOW; Apr 17th, 2013 at 01:13 PM.

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