Annoying decimal point

  • Thread starter Thread starter Bruce
  • Start date Start date
B

Bruce

I have a report containing a sum. Sometimes the sum is a
whole number, sometimes it has one decimal place, and
sometimes two. The number format #.## does what I want
except that it keeps the decimal point for a whole number
(i.e. 3.). Is there a way of supressing the decimal point
if the result is a whole number? I can sort of imagine
that an IIf statement could take care of it, but I'm not
sure how to put that together or where to put it. A minor
issue, but it keeps cropping up.
 
Hi Bruce,

Try using an expression in the textbox on the report, something along
the lines of

=IIF(Abs(X-Int(X))>=0.005,Format(X,"#.##"),Format(X,"#0"))

replacing X with [FieldName]
 
Thanks, that worked perfectly. I think I almost
understand why it worked, now that I've seen it.
-----Original Message-----
Hi Bruce,

Try using an expression in the textbox on the report, something along
the lines of

=IIF(Abs(X-Int(X))>=0.005,Format(X,"#.##"),Format(X,"#0"))

replacing X with [FieldName]

I have a report containing a sum. Sometimes the sum is a
whole number, sometimes it has one decimal place, and
sometimes two. The number format #.## does what I want
except that it keeps the decimal point for a whole number
(i.e. 3.). Is there a way of supressing the decimal point
if the result is a whole number? I can sort of imagine
that an IIf statement could take care of it, but I'm not
sure how to put that together or where to put it. A minor
issue, but it keeps cropping up.

--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.
.
 
Back
Top