April 21, 2008 at 11:01 pm
The following expression :
=IIf(Not IsNothing(Parameters!Rejected.Value), Parameters!Rejected.Value.ToString(), "Null")
gives the following error when the parameter is null:
"Object reference not set to an instance of an object."
So I am only trying to display the value of the parameter when it is not null but it still won't work. Can someone point me to the solution please.
Thanks,
April 21, 2008 at 11:57 pm
I don't now what's wrong with the expression, but I get the same error. You can work around it by replacing [font="Times New Roman"]Parameters!Rejected.Value.ToString()[/font] with [font="Times New Roman"]CStr(Parameters!Rejected.Value)[/font]. Looks like both the true and the false argument are evaluated before calling the Iif function.
Peter
April 22, 2008 at 12:25 am
Yip - as I've since found out both expressions are always evaluated. I solved it by writing a small function in the Report/Parameters/Code tab. Great way to learn VB - in that little box with no support what-so-ever.
April 22, 2008 at 5:06 am
I just gave CStr(Parameters!Rejected.Value) a go since its a lot more convenient than writing a custom function. However what I forgot is that it doesn't allow you to choose what to display instead of null - which I wanted to do - so I'm going with my custom function for now. So in the Code tab I added the following:
Public Shared Function HandleNull(ByVal Param As Microsoft.ReportingServices.ReportProcessing.ReportObjectModel.Parameter) As String
If Param.Value Is Nothing Then
Return "All"
Else
Return Param.Value.ToString()
End If
End Function
and then in my text box I call it as:
Code.HandleNull(Parameters!Rejected)
April 22, 2008 at 10:45 am
Your initial expression returned the string "Null" in case the parameter was null. Just replace the "Null" string with "All":
=IIf(IsNothing(Parameters!Rejected.Value), "All", CStr(Parameters!Rejected.Value))
There's no need for VB if i look at your function.
Peter
April 22, 2008 at 3:30 pm
Ar... good point batman... thanks for that.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply