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

Decimal places - automatically determined 1

Status
Not open for further replies.

Betsvigi9

IS-IT--Management
May 31, 2001
46
GB
I am new to Crystal Reports. Does anyone know if there is a way to allow Crystal Reports to automatically determine the appropriate number of decimal places as, for example, does Access.

I am producing a recipe book from a database and whilst some of the ingredients do not require any decimal places to be shown others do. For example 110 grams is confusing to read if it is 110.00 grams whereas 0.25 or 0.5 of something needs decimal places to make sense. At the moment I cannot find any way of doing this, is it possible?

Thanks
 
It is automatically deciding, and it's decided that all of them are 2 because of the default settings.

You can write rules into the decimal formula, but you have to post what they're going to be.

In general you can use something like:

if {table.value) <> int({table.value}) then
2
else
0

So that if there aren't any decimals in the value it will not show decimals, otherwise it will show 2.

-k
 
File > Options > Field for Crystal 10, something similar for other versions. You can set the default value.

One problem - if someone else uses your report, they may have different defaults.

Fields can also be given their own formatting, right-click and Format Field. There is also ToText({your.value}, 0) which would show it as text with no decimal places. ToText takes time to write but is secure whoever runs it.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Thanks, that's exactly what I needed to know.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top