Solved

Trouble getting Subreport to work in VB Windows Form

Posted on 2011-03-19
12
300 Views
Last Modified: 2012-06-27
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

0
Comment
Question by:dyarosh
  • 5
  • 5
  • 2
12 Comments
 
LVL 1

Expert Comment

by:RADONE242
ID: 35184327
Could you use one table for dependents then just group this table by employee eliminating the need for a sub table?
0
 

Author Comment

by:dyarosh
ID: 35185149
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.
0
 
LVL 1

Expert Comment

by:RADONE242
ID: 35188812
So this is a listing of employees with two sub reports, one for dependents and one for the employee history?
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

Author Comment

by:dyarosh
ID: 35189932
Correct.  Right now I am just trying to get the first subreport to work.  Can't figure out what I'm doing wrong.
0
 
LVL 5

Expert Comment

by:puffdaddy411
ID: 35190982
Does the data from your main report list object from "Employee" populate correctly (with the subreport error below each employee info)?
0
 

Author Comment

by:dyarosh
ID: 35191139
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.
0
 
LVL 5

Expert Comment

by:puffdaddy411
ID: 35191197
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.
0
 
LVL 5

Expert Comment

by:puffdaddy411
ID: 35191271
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.
0
 

Author Comment

by:dyarosh
ID: 35191319
Yes,  Currently the Employee Section of the Report displays fine and is correct for each employee.
0
 
LVL 5

Accepted Solution

by:
puffdaddy411 earned 500 total points
ID: 35191458
I think I see the issue.


        Dim rptDataSource As New ReportDataSource("EmployeeListingDataSet", Me.EmployeeListingDataSet.Dependents)
        e.DataSources.Add(rptDataSource)


The "EmployeeListingDataSet" should be "EmployeeListingDataSet_Dependents".  You just need to specify the table by adding "_Dependents" to your dataset string.
0
 

Author Closing Comment

by:dyarosh
ID: 35192659
I can't thank you enough.  I can't believe it was such a simple solution.
0
 
LVL 5

Expert Comment

by:puffdaddy411
ID: 35192674
You're Welcome!
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Help with Query not working in client's PC 1 37
Help with LINQ and XML 10 36
How to retrieve a mysql date column that has 0000-00-00 in vb.net 8 35
SqlServer no dupes 25 35
This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question