• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 940
  • Last Modified:

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.
0
Sashaski
Asked:
Sashaski
  • 3
  • 2
1 Solution
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Try this

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

mx
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
OR this:



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

mx
0
 
Dale FyeCommented:
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)
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
SashaskiAuthor Commented:
Brilliant!  Amazing the time blown on the small things...I appreciate you!
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
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
0
 
SashaskiAuthor Commented:
Great tip to add to my plethora of tips, in fact I should create a database for database tips!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now