Link to home
Start Free TrialLog in
Avatar of dyarosh
dyarosh

asked on

Trouble getting Subreport to work in VB Windows Form

I have a Windows Form that uses Windows ReportViewer for displaying a report.  The report is similar to a master - detail report in that it displays employee information and displays dependent information as a subreport.  I am getting an error saying the subreport can not be displayed and I don't know why.  I've included the code below and the report definition:

DataSet: EmployeeListingDataSet - contains two tables, Employee and Dependents
ReportViewer1: Contains EmployeeListing.rdlc

EmployeeListing.rdlc Information
========================
Report Paramenters: None
Report Data Source: EmployeeListingDataSet_Employee
A List is used in the report for displaying the Employee Data
List Properties:  Data Set name: EmployeeListingDataSet_Employee; Detail Grouping: EmployeeID

Dependents Subreport Properties: Name: EmployeeListingDependents_subreport;  Subreport: EmployeeListingDependents;  Paramters: Parameter Name - EmployeeID; Parameter Value - Fields!EmployeeID.Value

EmployeeListingDependents.rdlc Information
=================================
Report Parameters: EmployeeID
Report DataSource: EmployeeListingDataSet_Dependents
A Table is used to display Dependent info
Table Properties: Data set name: EmployeeListingDataSet_Dependents;  Filter: Fields!EmployeeID.Value = Parameters!EmployeeID.Value

Any help would be greatly appreciated!
Imports Microsoft.Reporting.WinForms

Public Class EmployeeListing
    Private Sub EmployeeListing_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'EmployeeListingDataSet.Dependents' table. You can move, or remove it, as needed.
        Me.DependentsTableAdapter.Fill(Me.EmployeeListingDataSet.Dependents)
        'TODO: This line of code loads data into the 'EmployeeListingDataSet.Employee' table. You can move, or remove it, as needed.
        Me.EmployeeTableAdapter.Fill(Me.EmployeeListingDataSet.Employee)
        AddHandler Me.ReportViewer1.LocalReport.SubreportProcessing, AddressOf DependentsSubreportProcessingEventHandler

        Me.ReportViewer1.RefreshReport()
    End Sub

    Public Sub DependentsSubreportProcessingEventHandler(ByVal sender As Object, _
     ByVal e As SubreportProcessingEventArgs)
        Dim rptDataSource As New ReportDataSource("EmployeeListingDataSet", Me.EmployeeListingDataSet.Dependents)
        e.DataSources.Add(rptDataSource)
    End Sub

End Class

Open in new window

Avatar of RADONE242
RADONE242

Could you use one table for dependents then just group this table by employee eliminating the need for a sub table?
Avatar of dyarosh

ASKER

I can try but I need to add another "subreport" for employee history and joining thAt data with the employee and dependent data gets tricky.
So this is a listing of employees with two sub reports, one for dependents and one for the employee history?
Avatar of dyarosh

ASKER

Correct.  Right now I am just trying to get the first subreport to work.  Can't figure out what I'm doing wrong.
Does the data from your main report list object from "Employee" populate correctly (with the subreport error below each employee info)?
Avatar of dyarosh

ASKER

I'm not sure what you are asking.  The field that is used to connect the main Employee Report with the Dependent Subreport is shown on the Employee Report.
What I meant was, if you removed the subreports and only had one report with your List object as your described here:

===========================
A List is used in the report for displaying the Employee Data
List Properties:  Data Set name: EmployeeListingDataSet_Employee; Detail Grouping: EmployeeID
===========================


Will the LIST ONLY display correctly?  I'm just starting from the beginning to get an idea of everything going on.
My next question would be, can you test the functionality of the objects in your subreport by creating a temp/test report?  Maybe filter it by on employeeID.....just to see if all your groupings/settings/filters work in the table within your subreport.
Avatar of dyarosh

ASKER

Yes,  Currently the Employee Section of the Report displays fine and is correct for each employee.
ASKER CERTIFIED SOLUTION
Avatar of puffdaddy411
puffdaddy411

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dyarosh

ASKER

I can't thank you enough.  I can't believe it was such a simple solution.
You're Welcome!