Select the product you need help with
- Internet Explorer
- Windows Phone
- More products
ACC2000: How to Round a Number Up or Down by a Desired Increment
Article ID: 209996 - View products that this article applies to.
This article was previously published under Q209996
Moderate: Requires basic macro, coding, and interoperability skills.
This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).
This article shows you how to create a procedure that rounds a number up or down by a specified increment. For example, given the number 3.23, rounding to the nearest .05 results in the number 3.25. The procedure in this article accepts any positive rounding increment as a parameter. In addition to rounding numbers to the nearest fractional amount, you can also round to whole numbers, such as 1, 10, or 100.
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
The following example creates a user-defined function called RoundToNearest, which accepts three parameters:
Collapse this tableExpand this table
For additional information about rounding, click the article numbers below to view the articles in the Microsoft Knowledge Base:
(http://support.microsoft.com/kb/210564/EN-US/ )ACC2000: Round or Truncate Currency Values to the Intended Number of Decimals
(http://support.microsoft.com/kb/210423/EN-US/ )ACC2000: Rounding Errors When You Use Floating-Point Numbers