I have created an application in VS 2005 pulling reports created in Crystal Reports XI Release 2. My problem is I have a couple of reports that have linked subreports on them. Does anyone know how to pass a parameter value to a subreport in .NET? I have the following code snippet and it works except that the same data appears in the subreport for all the main reports; unlinking the subreports.
I was originally told that you couldn't pass parameter values to a subreport - to create a parameter on the main report and link to the subreport - which is what I did, but now the reports don't seem to be linked.
Dim lpfdDefinitions As ParameterFieldDefinitions = objReport.DataDefinition.ParameterFields Dim lpfdDefinition As ParameterFieldDefinition = lpfdDefinitions.Item(lSubreport.ParaName) lpfdDefinition.ApplyCurrentValues(lSubreport.Values) mobjReport.OpenSubreport(lSubreport.SubName).SetDataSource(lSubreport.DataTable) mobjReport.SetParameterValue(lSubreport.ParaName, lSubreport.Values.ToArray()) mobjReport.SetParameterValue("PM-@" & lSubreport.ParaName, lSubreport.Values.ToArray(), lSubreport.SubName)
"lSubreport.Values" is loaded higher up in the code by values coming from the main report.
"lSubreport.DataTable" is the datatable that is loaded from the subreport's SQL Query. Any help with this would be greatly appreciated.