Solved

Rounding A Calculated Field in an Access Query

Posted on 2011-09-21
6
346 Views
Last Modified: 2012-08-13
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
Comment
Question by:Sashaski
  • 3
  • 2
6 Comments
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 250 total points
ID: 36575988
Try this

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

mx
0
 
LVL 75
ID: 36576004
OR this:



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

mx
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 36576009
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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

Author Closing Comment

by:Sashaski
ID: 36576069
Brilliant!  Amazing the time blown on the small things...I appreciate you!
0
 
LVL 75
ID: 36576104
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
 

Author Comment

by:Sashaski
ID: 36576129
Great tip to add to my plethora of tips, in fact I should create a database for database tips!
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question