In rdlc report. A subreport was created 4 parameters for received from main report. But sometime a main report may send less than four value. For example: A String was sent from these VB.Net code.
Dim strProcessCode As String = {"A,B"}
A string includes only two value.(A and B) So I using splitted this string by using expression for each parameter like these
=iif(Split(Parameters!pProcessCode.Value, ",").Length>0,
(Split(Parameters!pProcessCode.Value, ",")).GetValue(0)
,nothing) ''For first parameter
First and second parameters is fine. But It has a problem when I prepared a value for third parameter. Despite it used the same way.
=iif(Split(Parameters!pProcessCode.Value, ",").Length>2,
(Split(Parameters!pProcessCode.Value, ",")).GetValue(2)
,nothing) ''For third parameter
It show this error message
Error: Subreport could not shown.
How to fixed it?
It would be easier to read and maintain if you could break it down into an If.. ElseIF.. Else
or a Select
.
Function ReturnResult(byval pProcessCodeValue as string) as string
If Instr(0, pProcessCodeValue,",",vbTextCompare) = 0 Then
ReturnResult = pProcessCodeValue
Exit Function
End If
dim arr() as string
arr = Split(pProcessCodeValue , ",")
ReturnResult = arr(arr.Length)
End Function
Call it:
=ReturnResult(Parameters!pProcessCode.Value)
However, with SSRS you may need to use nested IIF's, eg:
=iif(Split(Parameters!pProcessCode.Value, ",").Length = 0,
(Split(Parameters!pProcessCode.Value, ",")).GetValue(0)
, iif(Split(Parameters!pProcessCode.Value, ",").Length = 1,
(Split(Parameters!pProcessCode.Value, ",")).GetValue(1)
, iif(Split(Parameters!pProcessCode.Value, ",").Length = 2,
(Split(Parameters!pProcessCode.Value, ",")).GetValue(2)
, nothing))
)