473,508 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Rounding Up in Access

418 Contributor
I have a field called GrossAmount that shows amount in two decimal format. I need to calculate a field called NetAmount where the amount needs to be rounded up. How do I do it in Access? Anyone out there to help, please?

Data type for both the fields are "Currency"

Thanks.
Apr 27 '09 #1
16 6287
ChipR
1,287 Recognized Expert Top Contributor
Since the Round() function uses round-to-even logic, I would be more likely to use:
Expand|Select|Wrap|Line Numbers
  1. IIf( amount = Int( amount ), amount, Int( amount ) + 1)
If the amount is an integer, return the amount, otherwise return the integer part of the amount plus 1.
Apr 27 '09 #2
FishVal
2,653 Recognized Expert Specialist
Rounding .
Apr 27 '09 #3
MNNovice
418 Contributor
Thanks. I will try and shall get back.
Apr 27 '09 #4
ChipR
1,287 Recognized Expert Top Contributor
Thanks Fish, that's pretty interesting.
Expand|Select|Wrap|Line Numbers
  1. -Int( -amount )
Much better.
Apr 27 '09 #5
NeoPa
32,557 Recognized Expert Moderator MVP
Certainly the best approach to the problem (that I've ever discovered).

The beauty is that the Int() function is not restricted to returning only an Integer. It's return is a Variant. It can handle even more digits than a Long. This should not be confused with the CInt() function.

Remember for currency though, that you need to multiply by 100, then divide the result, to get it to round at the penny or cent position. Be careful to ensure the calculation is not treated as a Long or Integer. If it is, the division will fail to work as expected.
Apr 27 '09 #6
ChipR
1,287 Recognized Expert Top Contributor
I just thought of
Expand|Select|Wrap|Line Numbers
  1. Round(amount+.499)
which should work since the amount should only go to 2 decimal places. Probably Int() is faster though.

NeoPa: I don't understand what you mean by multiply by 100, then divide the result, when rounding a currency or decimal to an integer.
Apr 28 '09 #7
MNNovice
418 Contributor
ChipR:

Is this the correct way to write the formula in the control for NetAmount?

= int([GrossAmount])

Thanks.
Apr 28 '09 #8
ChipR
1,287 Recognized Expert Top Contributor
If you want it to be rounded up, you would need to use
Expand|Select|Wrap|Line Numbers
  1. = -Int(-[GrossAmount])
Since Int() rounds numbers down. When we make the number negative and round down, we get a bigger negative number, then we just negate it again and get the positive.
Like:
Expand|Select|Wrap|Line Numbers
  1. -Int(-[5.5]) = -Int(-5.5) = -(-6) = 6
Apr 28 '09 #9
MNNovice
418 Contributor
ChipR:

It works but not the way I need it to. Perhaps I didn't explain my problem clearly. Let's say if the GrossAmount is $100.39, I need the NetAmount to show as $100. If the GrossAmount is $100.67, then the NetAmount is to read as $101.

With the formula = -Int(-[GrossAmount]), $100.39 becomes $101 as NetAmount and the GrossAmount is displayed as $100. Question: Why does the GrossAmount gets changed? It should display as what is entered, in this case it was $100.39.

Thanks.
Apr 28 '09 #10
ChipR
1,287 Recognized Expert Top Contributor
I was under the impression that you wanted to round up, since that is what you said in your first post. To do normal rounding, do:
Expand|Select|Wrap|Line Numbers
  1. =Round([GrossAmount]+.0001)
Apr 28 '09 #11
MNNovice
418 Contributor
ChipR: It's working great. Many Thanks.
Apr 28 '09 #12
ChipR
1,287 Recognized Expert Top Contributor
No problem, interesting topic.
Apr 28 '09 #13
FishVal
2,653 Recognized Expert Specialist
Gentlemen, here is a thread where some interesting aspects of Round() function were discussed.
Apr 28 '09 #14
NeoPa
32,557 Recognized Expert Moderator MVP
@ChipR
This depends on the requirement.

If the requirement is to round the pence up (to a whole currency amount - £, $ etc), then this wouldn't be required.

If, on the other hand, it is to round up a calculated result to the next higher penny or cent value, then you would need something like :
Expand|Select|Wrap|Line Numbers
  1. =CCur(-Int(-[Calculated Currency Value]*100) / 100
Apr 28 '09 #15
ChipR
1,287 Recognized Expert Top Contributor
Ah, I see what you mean. Thanks for clarifying.
Apr 28 '09 #16
NeoPa
32,557 Recognized Expert Moderator MVP
Always happy to help Chip. Especially those who contribute so much to the site :)
Apr 28 '09 #17

Sign in to post your reply or Sign up for a free account.

Similar topics

3
9373
by: Dalan | last post by:
Is there any code available to address currency rounding problems in Access 97? Apparently, selecting currency type table fields does not resolve the problem. For instance, in my form I have a...
1
15461
by: Mike MacSween | last post by:
This looks like a bug to me. I have an expression on a report: =Format(Sum((**)*(/)),"0.00") Score is byte PercentOfGrade is double PropDegree is single ModuleCats is byte
2
5105
by: Lynn N. | last post by:
I have a report showing Rate, Hours and Total Pay (which is Rate*Hours) for several workers. I want to sum the Total Pay and get a CORRECT figure. This seems like it should be such a simple task....
6
3395
by: DaveK | last post by:
I am upgrading an MS Access 97 application which uses the format function to round decimal numbers to two places e.g. format(dblValue, "standard") Having done an initial study of this...
13
1706
by: dhildebrandt | last post by:
I have a query that uses the Round function to change decimals into whole numbers. For 4 years straight the thing has always rounded the numbers in exactly the same way so that whenever I update...
8
2066
by: Zorpiedoman | last post by:
Howcome: Dim D as decimal = .5D msgbox d.Round(D, 0) this returns "0" Now when I went to school .5 rounds UP to 1 not DOWN to zero?????!!! Documentation says this, but what the heck are...
6
2239
by: shaqattack1992-newsgroups | last post by:
Hello Everyone, I'm using the following on a form in my database: =(-Int(-Sum((IIf(=Yes,((*)+()), (((*)+)*1.06))*100))))/100 In this case, I want to calculate a total for an order. If...
3
2262
by: gabo22003 | last post by:
Hello, I've inherited a tax report where all of the financial numbers are currency.This is a detailed report that lists amount, tax and total for that day ( total is listed in the database). The...
206
13093
by: md | last post by:
Hi Does any body know, how to round a double value with a specific number of digits after the decimal points? A function like this: RoundMyDouble (double &value, short numberOfPrecisions) ...
20
4958
by: jacob navia | last post by:
Hi "How can I round a number to x decimal places" ? This question keeps appearing. I would propose the following solution #include <float.h> #include <math.h>
0
7224
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7118
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5625
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5049
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
415
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.