riceman0
asked on
Passing Crystal Reports SelectionFormula along to a subreport
Hey, I'm struggling through incorporating a crystal report into my ASP.NET web page. My method is to create a DAO connection to my MDB file in my .rpt, and then on my report form with the CR viewer, I set up a selection formula as in the code below. As you can see I narrow the report down to a detailed report of a single record.
So now I have to add a second table based on a related database table (the "milestones" associated with my plan record), and apparently I have to do this using a subreport. I have created a separate, working RPT object that lists ALL of the milestones for all plans, and I added a subreport to my Plan report and connected it to this RPT. This works fine so far, I open up my plans report and I see the subreport listing all milestones for all plans, however I'd like to filter this down using the same SelectionFormula so that it only shows records in the subreport that pertain to the main report. How do I set a SelectionFormula for the subreport from my main webform / report viewer?
A code snippet (hopefully it's that simple) would be *much* appreciated. Thanks very much...
So now I have to add a second table based on a related database table (the "milestones" associated with my plan record), and apparently I have to do this using a subreport. I have created a separate, working RPT object that lists ALL of the milestones for all plans, and I added a subreport to my Plan report and connected it to this RPT. This works fine so far, I open up my plans report and I see the subreport listing all milestones for all plans, however I'd like to filter this down using the same SelectionFormula so that it only shows records in the subreport that pertain to the main report. How do I set a SelectionFormula for the subreport from my main webform / report viewer?
A code snippet (hopefully it's that simple) would be *much* appreciated. Thanks very much...
Partial Class FormReportPlan
Inherits System.Web.UI.Page
Private customerReport As ReportDocument
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
ConfigureCrystalReports()
End Sub
Private Sub ConfigureCrystalReports()
Dim rec As String = Request.QueryString("rec")
customerReport = New ReportDocument()
customerReport.Load(Server.MapPath("ReportPlan.rpt"))
If Not rec Is Nothing Then
CrystalReportViewer1.SelectionFormula = "{Plans_View.Plan Number} = '" + rec + "'"
End If
CrystalReportViewer1.ReportSource = customerReport
End Sub
End Class
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
"WHy do you need to add this as a subreport?"
Please see my accepted answer to this question. I would love to do this more simply.
https://www.experts-exchange.com/questions/23469076/ASP-NET-Crystal-report-with-multiple-tables.html
"If it is a related table you should be able to simply add the table to the main report and link it appropriately."
Do you still think I can do this? I want several different tables/lists.
You are correct, in that scenario you need to use subreports.
mlmcc
mlmcc
If it is a related table you should be able to simply add the table to the main report and link it appropriately.
To use the subreport links
Right click the subreport
Click CHANGE SUBREPORT LINKS
Select the ID field from the main report
Select the related foield from the subreport field list
CLick the box the select records based on the field
mlmcc