Wednesday, March 28, 2012

How to format a number field..

i have a number field but i can't seem to make a format out of it..
e.g.
when i have a value of 1, i want to make it appear in the report like 0000000001 or if i have 11, i want to make it appear like 0000000011
Hope someone could help!
thanksHello DarylAps,

You have two options :

1. While selecting records from table itself use replicate function (assuming you are using mssql server ) and return formatted number.
or
else

2. Create a formula as shown below : assuming your numeric field name is col :

ReplicateString('0', 10-Length ({SqlCommand.col} ) )+{SqlCommand.col}

Here are the details of ReplicateString functions of CR :

ReplicateString (str, #copies)
Basic and Crystal syntax.

Arguments
str is the text string to be replicated.
#copies is a whole number indicating the number of times str is to be replicated.

I hope you like this resolution.

Thanks
Dilemma

No comments:

Post a Comment