Hi All!
I was checking the value of a field and if it is empty sending empty string to the textbox if not only the first few values and it is working but on the empty field something like "#Error" is being displayed.
here is the code:
=Iif(Fields!Lname.Value <>””, Fields!Lname.Value.ToString().Substring(0,10),"")
What I want to acheve is : If it is not zero to take the first 10 characters and if not to send an epmity string to the textbox.
Any help plz?
Thank you in advance!
In your expression, you are making the assumption that the string will be at least 10 characters. If it isn't 10 characters you will get an error. I am not sure what you are trying to accomplish but see the expression below. It will truncate the field if it is over 10 characters.
=Iif(Fields!Lname.Value.ToString().Length() > 10, Fields!Lname.Value.ToString().Substring(0,10), Fields!Lname.Value)
|||
here is the code:
=Iif(Fields!Lname.Value <>””, Fields!Lname.Value.ToString().Substring(0,10),"")
What I want to acheve is : If it is not zero to take the first 10 characters and if not to send an epmity string to the textbox
Thank you.The one that you send to me is not doing what i was looking for. Thank you very much.
|||My expression does the exact same thing as yours except when there are less than 10 characters it will not attempt to truncate.
Input and output for my expression:
Input and output for your expression
If I am getting it right, the problem I think is that when that field is empty or NULL, it returns an error:
So in your code actually, the first line for input and output would be:
"" --> #Error
I dunno how to resolve this in RS as I tried various things and they didn't work (like length = 0 etc.), only thing I can think of for now is to modify your query itself to return the substring instead of the field and then use this new field..
e,g,
select .....,..,.., substring(ISNULL(OldFieldName,''), 0, 10) as NewFieldName
from TableName
|||Ryan Ackley MSFT wrote:
My expression does the exact same thing as yours except when there are less than 10 characters it will not attempt to truncate.
Input and output for my expression:
"" -> "" "foo" -> "foo" "bar" -> "bar" "SomeReallyLongString" -> "SomeReally"
Input and output for your expression
"" -> "" "foo" -> "#Error" "bar" -> "#Error" "SomeReallyLongString" -> "SomeReally"
Thank you very much. This is exactly what the problem that I am facing now let me try to see some other things and I will do as you suggest. Thank you.If you find anything new plz let me know.
Ephi
No comments:
Post a Comment