cancel
Showing results for 
Search instead for 
Did you mean: 

Sub Report Parameters

Former Member
0 Kudos

Here is a simplified example of what I am trying to do... I simply want to be able to set a parameter in a

sub report (the sub report was dynamically added using RAS) to some value... this example does not work.

Can anyone correct the syntax in this example so it works:


Dim objParameterFieldDefinitions As CrystalDecisions.ReportAppServer.DataDefModel.Fields
Dim objParameterFieldDefinition As CrystalDecisions.ReportAppServer.DataDefModel.ParameterField
Dim objNewParameterFieldDefinition As CrystalDecisions.ReportAppServer.DataDefModel.ParameterField
objParameterFieldDefinitions = boSubreportClientDocument.DataDefController.DataDefinition.ParameterFields

Dim strValue as string = "Hello"

For Each objParameterFieldDefinition In objParameterFieldDefinitions
     If objParameterFieldDefinition.Name = "Test" Then
        objNewParameterFieldDefinition = objParameterFieldDefinition.Clone(True)
        Dim objParameterDescreteValue As New _
        CrystalDecisions.ReportAppServer.DataDefModel.ParameterFieldDiscreteValue

        objParameterDescreteValue = objParameterFieldDefinition.Values
        objParameterDescreteValue.Value = strValue   'THIS IS NOT VALID...  NOT SURE HOW TO SET THE VALUE

        objParameterValues = objNewParameterFieldDefinition.Values
        objParameterValues.Add(objParameterDescreteValue)
              
        boSubreportClientDocument.DataDefController.ParameterFieldController.Modify( _
        objParameterFieldDefinition, objNewParameterFieldDefinition)
    End If
Next

Thanks,

Jeff

Accepted Solutions (1)

Accepted Solutions (1)

former_member200290
Contributor
0 Kudos

I would suggest to set the parameter from the main report like this:

boMainreportClientDocument.DataDefController.ParameterFieldController.SetCurrentValue(boSubreportClientDocument.Name, strName, strValue)

Typically the way the parameters used to work with the other .NET SDK was that all parameters in the report including the subreport were concidered to be owned by the main report and set through the main report object. In my scenerio the above worked.

Trevor

Former Member
0 Kudos

Thanks Trevor!

You were correct - I put together a smaller sample and this worked great. I just need to figure out what I am doing wrong in my main application.

Thanks,

Jeff

Answers (0)