on 07112008 8:38 AM
I have created a field {@years} with the value 10 which was used as part of a formula. This part has worked fine. I also wanted to use {@years} as part of the report heading where 10 represented a time period. However, the number came up as 10.00. I used the formula Truncate(Abs({@years})) but only the Abs part seemed to work. The number came up as 10.00 instead of 10.
Is there a problem with the formula I'm using or with Crystal Reports X or something else?
Regards
Jorge
or if you're using it inside an HTML formatted text box as part
of a string you can say:
ToText({@years},0,"") ...and this will get rid of the decimal.
The Panda
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Panda,
Your suggestion certainly removes the decimal places, however it leaves the number in the negative.
I tried to use Abs within your formula ToText(Abs({@years},0,"")) but it says that too many arguments have been given to the function. Any idea where I go to from here?

I thought to use Right (str, length) and it worked. I don't know if there is a more effecient way to do it but Right(ToText({@years},0,""),2) does the job. I now get 10 instead of 10.
Thanks Panda, would not have got this far without your help.
Regards
Jorge
Edited by: Jorge Guillen on Jul 14, 2008 9:38 AM
You said:
"I tried to use Abs within your formula ToText(Abs({@years},0,"")) but it says that too many arguments have been given to the function."
You've almost got it. Check that your parens are correct.
I haven't run this on my machine yet, but I see that
the Abs function is not ended after @years...you have } but not
) after that. See what I mean ?
The Panda
Here you go, I just ran it. First, here is the Abs function:
abs(2.0)
Then I place the abs function inside the ToText function:
ToText(abs(2.0), 0, "")
Notice how (2.0 is closed off with a paren  ")".
Yours is not closed off and the compiler thinks you are throwing (...giving) too many parameters to the Abs function (...which you are :).
The Panda
You should be able to doubleclick inside the text field in design view, then select the formula name within the field, right click the formula name, and click Format Field, go to the Number tab, etc.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your help Panda
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Jorge,
This is due to your default system number formatting. To customize:
Rightclick the field in your header, select Format Field, Number tab, and choose the correct number formatting you require.
Cheers,
Fritz
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Apologies Fritz,
I had another look at your advice after a suggestion by another forum member and you were right, except in Report view the wording was "Format Text..." and in Design View the wording was "Format {@fieldname}". Either way it worked but now I can't give you full points. Again my apologies.
Regards
Jorge
User  Count 

66  
25  
10  
7  
5  
4  
4  
4  
4  
3 
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.