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!

help with totext conversion 1

Status
Not open for further replies.

CRuser89

Programmer
May 18, 2005
79
US
Hi..I am using CR9 and I have the following formula in my report:

WhilePrintingRecords;
StringVar Data;
if {INVENTORY.ID_CODE}='TS4' then
if IsNull({INVENTORY.ID_NUM}) then
Data := "None" Else
Data := totext({INVENTORY.ID_NUM})

If INVENTORY.ID_NUM is a single digit value like 1, 2, 3, or 4, then Data returns the value correctly but if INVENTORY.ID_NUM has a decimal in it, 0.1, 0.2, etc, then the Data returns some ambigious value. Is there something I need to do to convert decimals before using totext to convert it to a string?

Thank you...
 
Try:

totext({INVENTORY.ID_NUM},1)

...to return a result with 1 decimal point.

-LB
 
Thank you for your reply. That helped me out alot. The result however is rounded out. For example, if I have .49, the data returned is .5. Do you know how I can get the exact value and not a rounded value?

Also, is there a way to not have the decimal if it's a whole number. For example 1, 2, 3 is returning as 1.0, 2.0, 3.0. If the data is .4 or .5, it would be nice to have the decimal but if it's a zero, is here a way to supress the 0 for whole numbers?

Thank you...
 
First, go to format field->number->customize->decimals and set it to 1.000001. Then below that set "rounding" to 0.000001. Then go back to "decimals"->x+2 and enter the following formula:

if val(right(totext({INVENTORY.ID_NUM},6),6)) = 0 then 0 else
if val(right(totext({INVENTORY.ID_NUM},6),5)) = 0 then 1 else
if val(right(totext({INVENTORY.ID_NUM},6),4)) = 0 then 2 else
if val(right(totext({INVENTORY.ID_NUM},6),3)) = 0 then 3 else
if val(right(totext({INVENTORY.ID_NUM},6),2)) = 0 then 4 else
if val(right(totext({INVENTORY.ID_NUM},6),1)) = 0 then 5

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top