all groups > sql server reporting services > april 2006 >
You're in the

sql server reporting services

group:

Correct syntax for Substring?


Correct syntax for Substring? Mike Harbinger
4/21/2006 8:50:39 AM
sql server reporting services:
I want to limit the length of a text box to 20 characters and using the
format below it works if the length is greater than 20 but gives an '#Error'
when less than 20. Is my syntax wrong?

=Iif(Fields!CustName.Value.ToString().Length() > 20,
Fields!CustName.Value.ToString().Substring(0,20), Fields!CustName.Value)



Thanks

Re: Correct syntax for Substring? Dan
4/21/2006 9:45:48 AM
Mike,

Instead of using the if statement, you could just use the Left()
function. This will return the left X characters of your string.

Try using =Left(Fields!CustName.Value, 20)

Regards,

Dan



[quoted text, click to view]
Re: Correct syntax for Substring? Mike Harbinger
4/21/2006 10:18:15 AM
Dan, as always, simple is best. I am still learning about functions so many
thanks !!
Chris

[quoted text, click to view]

AddThis Social Bookmark Button