none
Reports - Subreports -Parameters RRS feed

  • Question

  • This is one more request for help in creating a report with a subreport.  I’ve been researching and working on this for a few days, but just can’t get it to work.  I’m using Visual Studio 2010 and VB. 

    The main report (rptPhoneList_Main) has two columns; CompanyNum and CompanyName.  The subreport (rptPhoneList) has three columns CompanyNum, ContactName, and PhoneNum.  The report will be grouped by the CompanyNum, below the company number and name will appear each of our contacts and there phone numbers.  The reports are completed and work individually.  After creating the reports I followed these step:

    Created a WinForm and added a ReportViewer to the form. Selected rptPhoneList_Main as the report.

    On the rptPhoneList_Sub RDLC I created a parameter with the following settings

    General > Name = parmCompanyNum

    Available Values > Specific Values > Label = @CompanyNum                                                                Available Values > Specific Values > Value = <<ExpR>>                                                                          <<Expr>>  =First(Fields!FamilyCode.Value, "dsPhoneListSum")

    On the rptPhoneList_Main, I added a placeholder for the subreport with these property settings.

    General > Name = rptPhoneList_Main                                                                                                                 General > Use This report as a subreport: = rptPhoneList_Main 

    Parameter > Name = parmCompanyName                                                                                            Parameter > Value   = <<ExpR>>                                                                                                              <<Expr>>  =First(Fields!FamilyCode.Value, "dsPhoneListMain")

    I then add the code to the  form (frmPhoneList.vb)

    Imports System.Windows.Forms

    Imports Microsoft.Reporting.WinForms

    Public Class Form1

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

    'TODO: This line of code loads data into the 'CSAdbDataSet.tblCompany'             Me.tblCompanyTableAdapter.Fill(Me.CSAdbDataSet.tblCpmpany)

    'TODO: This line of code loads data into the 'CSAdbDataSet.tblContacts'        Me.tblPublishersTableAdapter.Fill(Me.CSAdbDataSet.tblPublishers)

            Me.ReportViewer1.RefreshReport()

        End Sub

    Private Sub ReportViewer1_Load(sender As System.Object, e As System.EventArgs) Handles ReportViewer1.Load

    AddHandler ReportViewer1.LocalReport.SubreportProcessing, AddressOf     ReportViewer1_SubreportProcessing

            ReportViewer1.LocalReport.Refresh()

        End Sub

    Protected Sub ReportViewer1_SubreportProcessing(ByVal sender As Object, ByVal e As Microsoft.Reporting.WinForms.SubreportProcessingEventArgs)

    e.DataSources.Add(New Microsoft.Reporting.WinForms.ReportDataSource("CSAdbDataSet"))

        End Sub

    End Class

               

    When I run the report the company information appears , but the contact information does not.  I think some is wrong with the link between the reports.  Any assistance or suggestions is greatly appreciated.

               

    ATA

    Thursday, July 24, 2014 10:29 PM