1
votes

I have a multi-value parameter how I check in iif condition that value of idex is null or not now, I am using this expression

IIF(IsNothing(Parameters!FR.Value(0))," ","Test")

My parameter is hidden and some thing it has 4 values or some time less than 4.

when I check that values of index 3 value(3) and there is no value in this index. I shows error. How I check the index value of parameter.

1
I think this could also be of some use: stackoverflow.com/questions/21237135/… - user3056839

1 Answers

3
votes

The first problem is that there is no object at index 3, not that the value of the object is Nothing, so you will get an error trying to access the Value property of an object that doesn't exist.

The second problem is that IIF is a function not a language construct, so all parameters are evaluated before the function is called regardless of the value of the boolean condition. I can't see a way of trying to access the Value(3) property without the IIF function blowing up in your face when it doesn't exist. You could try something convoluted like this:

=IIF(Parameters!FR.Count >= 4, Parameters!FR.Value(IIF(Parameters!FR.Count >= 4, 3, 0)), "")

but that is still going to blow up in your face when there are no parameter values selected at all.

The easiest and safest way to do it would be to create a custom code function to which you pass the multi-value parameter and the index you want:

Function Get_FR_by_Index(ByVal parameter As Parameter, ByVal index As Integer) AS String
  Dim Result As String
  Result = ""
  If parameter.IsMultiValue Then
    If parameter.Count >= index+1 Then
      Result = CStr(parameter.Value(index))
    End If 
  End If 

  Return Result
End Function

then use this function to access the result:

=Code.Get_FR_by_Index(Parameters!FR, 3)

Remember that the index is zero-based, so the first Value is index 0.