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

Conditional Formatting

Status
Not open for further replies.

Zugdud

IS-IT--Management
Feb 26, 2003
158
US
Howdy folks, I want make a value on my report print inside Parathesis (value) if the value is equal or less then 0.

Is there a way to do this? like:

if {orderrel.ORDRELVAL} <= 0 then else

Im using Crystal reports 8.5 connecting ODBC to a progress 9.1d database. Thanks
 
Hi !

I think this one will be ok.

if {orderrel.ORDRELVAL} <= 0 then
'(' + ToText({orderrel.ORDRELVAL},0) + ')'

/Goran
 
GENIOUS! Thankyou, that worked excellent
 
Genius, even. Me spelling that wrong probably took away some of the desired impression
 
Ok need to make a small adjustment, it seems to be converting the value to text which is getting rid of the .00 values. So if @discount is 403.55 its getting convetered to (403), id like it to be (403.55)
 
Ooops Nevermind I got it, my computer must have had a brain fart
 
Ok need to make a small adjustment, it seems to be converting the value to text which is getting rid of the .00 values. So if @discount is 403.55 its getting convetered to (403), id like it to be (403.55)
 
Change the second argument of the ToText function from 0 to 2 (# of decimal places).

If the field is numeric, then you can avoid the formula altogether by customizing the display format of the field: right click the field > Format Field > Number tab > pick the format you want (there's a default that looks like '(1123.00)' that should work for you), or alternatively, click 'Customize' and enter your desired format.

-dave
 
Hi !

If your number field have different number of decimals you can change your formula to something like this:

local numbervar loop;
local numbervar counter;
local numbervar dec_locate;
local numbervar dec_count;
local stringvar value;
local stringvar temp ;

value := totext({orderrel.ORDRELVAL},10);

if instrrev(value,".") <> 0 then
dec_locate:= length(value) - instrrev(value,".");

for loop:= 1 to length(value) do(
temp:= value;
if right(temp,1) = "0" then
(
value := temp [1 to length(temp) -1];
counter:= counter +1);
);

dec_count:= 10 - (counter - dec_locate);


'(' + ToText({orderrel.ORDRELVAL},dec_count) + ')';

/Goran
 
If all you want to do is change the formatting of the negative indicator and keep the field as a Number type for summary purposes, then just use conditional formatting.
Right-click on the Numeric field & choose Format.
On trhe Number tab, click Customize.
Click the X-2 button beside the Negatives property.
Enter the following formula:
if CurrentFieldValue <= 0 then crBracketedNegatives else crNoNegativeSign

Cheers


Bob Suruncle
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top