in

can't pass parameters to a sub report

Hi

I have a report which contains parameters. If this is just a single report on its own it works fine and I can pass the parameters in no problem. I am now trying to include this report as a subreport in another report and I can't pass the parameters in at all.

Here is the code

  'Access the specified parameter from the parameters collection    
        Dim parameter As ParameterFieldDefinition = crsSubreports.ReportDocument.DataDefinition.ParameterFields("@pool", "LeagueTable")
        Dim currentValues As CrystalDecisions.Shared.ParameterValues = parameter.CurrentValues
        currentValues.Clear()
        'Create a value object for Crystal reports and assign the specified value
        Dim newValue As New CrystalDecisions.Shared.ParameterDiscreteValue()
        newValue.Value = "A"
        'Now add the new value to the values collection and apply the collection to the report.    
        currentValues.Add(newValue)
        parameter.ApplyCurrentValues(currentValues)


        parameter = Nothing
        parameter = crsSubreports.ReportDocument.DataDefinition.ParameterFields("@userID", "LeagueTable")
        currentValues = parameter.CurrentValues
        currentValues.Clear()
        newValue.Value = "00000000-0000-0000-0000-000000000000"
        currentValues.Add(newValue)
        parameter.ApplyCurrentValues(currentValues)
        crvSubreports.ReportSource = crsSubreports

I get the error "Index was outside the bounds of the array. " on this line
   Dim parameter As ParameterFieldDefinition = crsSubreports.ReportDocument.DataDefinition.ParameterFields("@pool", "LeagueTable")

I presume I am accessing the parameter wrong. I have tried all permutations such as @pool and pool for the parameter name and LeagueTable and LeagueYable.rpt for the subreport name.
For the subreport, the object name is "LeagueTable" and the subreport name is "LeagueTable.rpt"

No idea what to do next

thanks a lot
andrea

Solution: can't pass parameters to a sub report

Your old code should now work:

currentValues = parameter.CurrentValues
currentValues.Clear()
newValue.Value = "00000000-0000-0000-0000-000000000000"
currentValues.Add(newValue)
parameter.ApplyCurrentValues(currentValues)