For those of you who have the same issue, I have resolved my problem. The
following is what I did to get the parameters to pass to the subreport
correctly.
Within the subroutine that I get each parameter for each subreport:
For Each lSubreport As SubreportItems In mcolSubreports.Values
Dim crSubReportDoc As ReportDocument
crSubReportDoc = mobjReport.OpenSubreport(lSubreport.SubName)
crSubReportDoc.SetDataSource(lSubreport.DataTable)
Dim lpfdDefinitions As ParameterFieldDefinitions =
crSubReportDoc.DataDefinition.ParameterFields
Dim lpfdDefinition As ParameterFieldDefinition =
lpfdDefinitions.Item("PM-" & lSubreport.ParaName)
For Each lRow As DataRow In mobjData.Rows '// I actually had to move
this routine here for it to pass the all the values correctly.
Dim lpdvValue As ParameterDiscreteValue = New
ParameterDiscreteValue
lpdvValue.Value = lRow("adID").ToString
lpfdDefinition.CurrentValues.Add(lpdvValue)
lSubreport.Values.Add(lpdvValue)
Next
lpfdDefinition.ApplyCurrentValues(lpfdDefinition.CurrentValues)
mobjReport.SetParameterValue("PM-" & lSubreport.ParaName,
lpfdDefinition.CurrentValues.ToArray(), lSubreport.SubName)
Next
This works great and I get the correct record linking the subreport with the
main report.
--
Cindy
[quoted text, click to view] "cdmunoz" wrote:
> What version of Crystal are you using? I'm using 10.
> --
> Cindy
>
>
> "marklar20@yahoo.com" wrote:
>
> > On Feb 12, 9:42 am, cdmunoz <cdmu...@discussions.microsoft.com> wrote:
> > > I've created areportthat summarizes a client's record, but then has a
> > > subreport attached that gives historical information.
> > >
> > > Okay, here's the issue. I can call thisreportand pass it the parameters
> > > needed through my .NET program and it works great if only 1 client is
> > > selected. However, if multiple clients are selected then the subreport will
> > > list every historical record for every client selected on each client's
> > > summaryreport.
> > >
> > > On thereport: under the subreport links - I have the checkbox "Select data
> > > in subreport based on field" checked. In the subreport - the parameter field
> > > is set to allow "Multiple values" and "Discrete values".
> > >
> > > In the program - I'm loading an array with each parameter value that's
> > > selected from the mainreport(each client's id) and then I'm setting thereport'sparameter value to that array.
> > >
> > > Here's a snippet of the code:
> > > For Each lRow As DataRow In DataSet.Rows 'Mainreport'sdataset
> > > Dim lpdvValue As ParameterDiscreteValue = New ParameterDiscreteValue
> > >
> > > lpdvValue.Value = lRow("ID").ToString
> > >
> > > CurrentParameterValues.Add(lpdvValue)
> > >
> > > ParameterArray.Add(lpdvValue)
> > > Next
> > >
> > > '*** then after loading the mainreport...
> > >
> > > If SubReportFlag Then 'Denotes whether a subreport is attached to thereport.
> > > Dim lpfdDefinitions As ParameterFieldDefinitions =
> > > objectReport.DataDefinition.ParameterFields
> > > Dim lpfdDefinition As ParameterFieldDefinition =
> > > lpfdDefinitions(ParameterName)
> > >
> > > lpfdDefinition.ApplyCurrentValues(CurrentParameterValues)
> > >
> > > objectReport.OpenSubreport(SubReportName).SetDataSource(subreportdataset)
> > > objectReport.SetParameterValue(ParameterName,
> > > ParameterArray.ToArray(), SubReportName)
> > > End If
> > >
> > > As stated previously, it works fine if the user selects 1 client, but not
> > > with multiple clients....what am I missing?
> > > --
> > > Cindy
> >
> > I'm having the same issue. Except mine is specific transaction data
> > for multiple accounts. My thinking is that there are multiple
> > sub reports based on the grouping of the data. I am not sure though.
> > I'll fill you in when I figure it out myself :/