Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

conditional formatting for # of decimal places 1

Status
Not open for further replies.

PAULCALLAGHAN

Technical User
Sep 4, 2001
165
CA
I'm currently using Crystal Reports version 8.5.

A user has asked me if it is possible to conditionally format the number of decimal places to display. If the value has 3 decimal places, then it will display 3. If another value, for the same filed only has 2 decimal places then it will only display 2.

Can someone please lend me a hand to build this formula into the conditions for displaying a certain field?

 
I got this formula or something like it from some helpful do gooder on here so I'll pass it along. Unfortunately I can't recall who it was who gave it to me or I would give them full credit here.

Place this formula in the X-2 section of the decimals when you are formatting your field.

Code:
WhileReadingRecords ; 
StringVar text :=  Totext ( {your field here} , 5) ;
NumberVar end  :=  length ( text ) ; 
NumberVar clip  := 
IIF ( Val ( text [ end - 0 to end ] ) <> 0, 5,
IIF ( Val ( text [ end - 1 to end ] ) <> 0, 4,
IIF ( Val ( text [ end - 2 to end ] ) <> 0, 3,
IIF ( Val ( text [ end - 3 to end ] ) <> 0, 2,
IIF ( Val ( text [ end - 4 to end ] ) <> 0, 1, 0))))) ;

clip



Thanks and best regards,
-Lloyd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top