decimals and zeros

  • Thread starter Thread starter Kim Smith
  • Start date Start date
K

Kim Smith

My question is that I have set my text box in a report to just give me one
decimal,
but how do I set it to drop the decimal when the value is 0.


example:


Change 3.40 to 3.4 but change 3.0 to 3


Just by setting decimal places to auto in text box properties I get all (.5)
to work its just when you do numbers like 3.2 and 3.6 that you get 3.20 and
3.60.

To recap if I have a row of numbers I would like:

3.2 -> to read as 3.2 not 3.20

3 -> to read as 3 not 3.0

2.2 -> to read as 2.2 not 2.20

4.5 -> to read as 4.5 not 4.50

Thanks
 
Kim Smith said:
My question is that I have set my text box in a report to just give me one
decimal,
but how do I set it to drop the decimal when the value is 0.


example:


Change 3.40 to 3.4 but change 3.0 to 3


Just by setting decimal places to auto in text box properties I get all (.5)
to work its just when you do numbers like 3.2 and 3.6 that you get 3.20 and
3.60.

To recap if I have a row of numbers I would like:

3.2 -> to read as 3.2 not 3.20

3 -> to read as 3 not 3.0

2.2 -> to read as 2.2 not 2.20

4.5 -> to read as 4.5 not 4.50

Hi Kim,
Here's ONE way of doing this.

Try putting the following in the Format of the textbox control on your report:
=IIf(Int([txtNum])=([txtNum]),Format([txtNum],"0"),Format([txtNum],"0.0"))

where [txtNum] is the name of the field that has the number values. Replace
[txtNum] with the name of the field on your report.

Basically, the above IIf condition compares the INT(num) with (num) and
formats it according to the result being true/false.

Hope this helps.

-Amit
 
Back
Top