views:

32

answers:

1

Hello!

I was wondering if there was a way in Crystal to do the following:

If a field has a character limit of 10 characters...and the data fed in has 11 characters, instead of showing truncated data, i'd like it to show ** . Excel has a function like this where if a column is too narrow for a field to show completely, it shows ###### instead of the data.

Is there a way to do this for numeric fields and string fields?

I have tried:

if length {DataTable1.Name} < 4 then {DataTable1.Name} else '****'

also,

if length {DataTable1.Name} > 4 then '*****'

Neither works. Any ideas?

+2  A: 

Using Crystal Syntax, this works for me:

If Length({DataTable1.Name}) < 4 Then {DataTable1.Name} Else '****'

Edit:
Since you can possibly have numbers, you'll want something more like this:

If Length(ToText({Command.ORD_NUM_VALUE})) < 4.00 
    Then ToText({Command.ORD_NUM_VALUE}) Else '****'

I get a little wary of casting like this though. Hopefully you can find a better solution for your problem.

Adam Bernier
this does work for strings...but a lot of my fields are numerical values. will it still work for that?
@yeahumok: updated answer to address this concern.
Adam Bernier