I am using crystal reports 2008.
I am trying to print an odometer number in a set form field on a page. I am using a formula field with the following syntax. This is working correctly for numbers greater than 9,999. But it does not work for less than 10,000 miles. My if totext() statement seems to not be working.
Example: for 9,964 is prints as 99,64 in the box fields but if the number is 33,167 it will space out correctly.
if {vehicle_title.odometer} = 0 then '' else
if {vehicle_title.odometer} < 10 then
' ' + ' ' + ' ' + ' ' + ' ' + ToText(Truncate({vehicle_title.odometer},0))[1] else
if {vehicle_title.odometer} < 100 then
' ' + ' ' + ' ' + ' ' + ToText(Truncate({vehicle_title.odometer},0))[1] + ToText(Truncate({vehicle_title.odometer},0))[2]
else
if {vehicle_title.odometer} < 1000 then
' ' + ' ' + ' ' + ToText(Truncate({vehicle_title.odometer},0))[1] + ToText(Truncate({vehicle_title.odometer},0))[2] + ToText(Truncate({vehicle_title.odometer},0))[3]
else
if Totext({vehicle_title.odometer})[2] = ',' then
' ' + ' ' + ToText(Truncate({vehicle_title.odometer},0))[1] + ' ' + ToText(Truncate({vehicle_title.odometer},0))[3] + ' ' + ToText(Truncate({vehicle_title.odometer},0))[4] +
' ' + ToText(Truncate({vehicle_title.odometer},0))[5] + ' ' else
if Totext({vehicle_title.odometer})[3] = ',' then
' ' + ToText(Truncate({vehicle_title.odometer},0))[1] + ' ' + ToText(Truncate({vehicle_title.odometer},0))[2] + ' ' + ToText(Truncate({vehicle_title.odometer},0))[4] +
' ' + ToText(Truncate({vehicle_title.odometer},0))[5] + ' ' + ToText(Truncate({vehicle_title.odometer},0))[6]
else
//if Totext({vehicle_title.odometer})[4] = ',' then
ToText(Truncate({vehicle_title.odometer},0))[1] + ' ' + ToText(Truncate({vehicle_title.odometer},0))[2] + ' ' + ToText(Truncate({vehicle_title.odometer},0))[3] +
' ' + ToText(Truncate({vehicle_title.odometer},0))[4] + ' ' + ToText(Truncate({vehicle_title.odometer},0))[5] + ' ' + ToText(Truncate({vehicle_title.odometer},0))[6]
Thanks!!
I am trying to print an odometer number in a set form field on a page. I am using a formula field with the following syntax. This is working correctly for numbers greater than 9,999. But it does not work for less than 10,000 miles. My if totext() statement seems to not be working.
Example: for 9,964 is prints as 99,64 in the box fields but if the number is 33,167 it will space out correctly.
if {vehicle_title.odometer} = 0 then '' else
if {vehicle_title.odometer} < 10 then
' ' + ' ' + ' ' + ' ' + ' ' + ToText(Truncate({vehicle_title.odometer},0))[1] else
if {vehicle_title.odometer} < 100 then
' ' + ' ' + ' ' + ' ' + ToText(Truncate({vehicle_title.odometer},0))[1] + ToText(Truncate({vehicle_title.odometer},0))[2]
else
if {vehicle_title.odometer} < 1000 then
' ' + ' ' + ' ' + ToText(Truncate({vehicle_title.odometer},0))[1] + ToText(Truncate({vehicle_title.odometer},0))[2] + ToText(Truncate({vehicle_title.odometer},0))[3]
else
if Totext({vehicle_title.odometer})[2] = ',' then
' ' + ' ' + ToText(Truncate({vehicle_title.odometer},0))[1] + ' ' + ToText(Truncate({vehicle_title.odometer},0))[3] + ' ' + ToText(Truncate({vehicle_title.odometer},0))[4] +
' ' + ToText(Truncate({vehicle_title.odometer},0))[5] + ' ' else
if Totext({vehicle_title.odometer})[3] = ',' then
' ' + ToText(Truncate({vehicle_title.odometer},0))[1] + ' ' + ToText(Truncate({vehicle_title.odometer},0))[2] + ' ' + ToText(Truncate({vehicle_title.odometer},0))[4] +
' ' + ToText(Truncate({vehicle_title.odometer},0))[5] + ' ' + ToText(Truncate({vehicle_title.odometer},0))[6]
else
//if Totext({vehicle_title.odometer})[4] = ',' then
ToText(Truncate({vehicle_title.odometer},0))[1] + ' ' + ToText(Truncate({vehicle_title.odometer},0))[2] + ' ' + ToText(Truncate({vehicle_title.odometer},0))[3] +
' ' + ToText(Truncate({vehicle_title.odometer},0))[4] + ' ' + ToText(Truncate({vehicle_title.odometer},0))[5] + ' ' + ToText(Truncate({vehicle_title.odometer},0))[6]
Thanks!!