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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TOTEXT Formatting for negative numbers

Status
Not open for further replies.

nlaliberte

Programmer
Apr 26, 2007
79
US
I'm using Crystal XI and a SQL Server connection.

My issue surrounds a value that I have to display as a string. When this value is negative it displays with a dash in front, we would like it to display in parenthesis (accounting format). I can't find the correct formatting to use in my TOTEXT function.

Currently: {table.currency} + TOTEXT({table.value},2)
$ + TOTEXT(-105.7689,2) = $-105.77

We would like it to display ($105.77).
 
Ian,

This ABS function (absolute value) simply converts my negative number into a positive one. $-105.77 = $105.77

What we need is the value to appear in parenthesis when it is negative. For example:

$105.77 = $105.77
$-105.77 = ($105.77)

 
Sorry

Just right click and format number object. Select Customise.

YOu will see a box called negative in drop down select (123)

It remains as a number. you can then add this formatted number to a text field which already contains field {table.currency}.

If you really need text

If {table.value} < 0 then
{table.currency} + "(" + TOTEXT(abs({table.value}),2)+ ")"
else
{table.currency} + TOTEXT(abs({table.value}),2)

Ian


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top