Link to home
Start Free TrialLog in
Avatar of Sashaski
Sashaski

asked on

Rounding A Calculated Field in an Access Query

Hi experts!  

Here is the code I'm using for my calculated field:

Percentage: ([quantity]*[makeup])/100

The result currently shows two decimal points.  I would like this field to round to the nearest whole number, no decimals.  Please help!

Thank you.
ASKER CERTIFIED SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
OR this:



Percentage: FormatNumber(([quantity]*[makeup])/100 , 0)

mx
Well, you could do it in the formatting of the field, just set the # of decimals to 0

Or you could use the Round() function:

Percentage: Round([quantity]*[makeup]/100)
Avatar of Sashaski
Sashaski

ASKER

Brilliant!  Amazing the time blown on the small things...I appreciate you!
You are welcome.

I actually like FormatNumber() better, because IF ... you need two dec pts, you can't get that with Round() - in some cases:

?Round(55/22,2)
 2.5

?FormatNumber(55/22,2)
2.50

mx
Great tip to add to my plethora of tips, in fact I should create a database for database tips!