Question : Pass the Selection Formula to the subreport

In my code behind I'm passing a Selection Formula to my report (Proposals.rpt).  This Proposals.rpt report that I'm passing the Selection Formula values to has a subreport within it called ProposalCostNotes.rpt.  How do I pass the Selection Formula values to the sub report so the subreport gets filtered propoerly?

Below is my sub routine that passes the Selection Formula to my Proposal.rpt.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
Private Sub BindReportWithSelectFormula()

        Dim intProposalNumber As Integer = "41772"
        Dim intRevisionNumber As Integer = "1"

        Dim mySelectionFormula As String = "{Proposals.ProposalNumber} = " & _
        intProposalNumber & " AND {Proposals.RevisionNumber} = " & _
        intRevisionNumber

        Dim report As New ReportDocument()
        report.Load(Server.MapPath("reports/Proposal.rpt"))

        SetTableLocation(report.Database.Tables)

        CrystalReportViewer1.ReportSource = report
        CrystalReportViewer1.SelectionFormula = mySelectionFormula

    End Sub

Answer : Pass the Selection Formula to the subreport

If the above doesn't work you can try:
report.Subreports.Item("ProposalCostNotes.rpt").RecordSelectionFormula = mySelectionFormula

Random Solutions  
 
programming4us programming4us