Hi there,
I'm having some trouble displaying a value as I'd like to a Crystal Report. As you may know, Crystal doesn't support decimal alignments (as the decimal tab stop in word does), so I wrote a routine to take care of that.
Originally, the field that I wanted to decimal align was a formula field with the following equation:
I figured I'd solve the decimal alignment issue by creating a formula that returned the numerical part of the result given on parameter's TRUE value, and the decimal part given the same parameters FALSE value, so I wrote the following function (SplitNumber):Code://Normally, the rounding routine would be in the display properties of the field. //Becuase the display properties are altered using the displaystring property, //we must round the number here. round(lbstokgs({Packages.WeightLbs}),1); lbstokgs: Function (NumberVar dbllbs) dbllbs * 0.45359237;
I duplicated the field I was having issues with twice, and in one field used the following formula for the display property (to display the integer portion):Code:Function (stringvar dInput, optional booleanvar bReturnIntegerPortion:=true) ( stringvar array sNumberValues; stringvar sInteger; stringvar sFraction; //Divide the number values into two values sNumberValues:=Split (dInput, "."); //Determine if either value should be zero if bReturnIntegerPortion=true then sNumberValues[1] else sNumberValues[2]; )
and the following formula for the decimal portion:Code:SplitNumber (totext(currentfieldvalue), true);
The formulas seem to work fine, except that no matter what I do I cannot get the decimal values to display in any other format other than two decimal points. I've tried using the round function and the truncate function, both in the display formula and in the @LbsToKgs formula, but to no avail - the decimal points still display two places.Code:"." & SplitNumber (totext(currentfieldvalue), false);
After setting the display formula, there is no longer a number tab, so I cannot change the rounding and display settings for the numerical return value.
Any ideas?


Reply With Quote