views:

840

answers:

1

Hello,

I'd like to display a string without the last 2 chars in a text field in Reporting Services 2005 vs2005. I tried several ways and if the string is empty or null I get an error: rsRuntimeErrorInExpression - The value expression for the textbox contains an error: Argument 'Length' must be greater or equal to zero.

Here are the ways I tried: IIF(trim(Fields!kuku.Value) = "","", Left(Fields!kuku.Value, Len(Fields!kuku.Value) - 2))

IIF(IsNothing(Fields!kuku.Value) and Len(Fields!kuku.Value) = 0,"",Left(Fields!kuku.Value, Len(Fields!kuku.Value) - 2))

IIF(IsNothing(Fields!kuku.Value) ,"",Left(Fields!kuku.Value, Len(Fields!kuku.Value) - 2))

IIF(Len(Fields!kuku.Value) = 0,"",Left(Fields!kuku.Value, Len(Fields!kuku.Value) - 2))

Any ideas as to what I'm doing wrong? Thanks in advance.

+2  A: 

how about changing the dataset on that field to use isnull(field,", ") that way you can always safely trim 2 characters.

or

IIF(IsNothing(Fields!kuku.Value) OR Len(Fields!kuku.Value) < 2,"",Left(Fields!kuku.Value, Len(Fields!kuku.Value) - 2))

note the and changed to an OR. And just in case the length is 1 changed =0 to <2

gjutras