Solved

Rounding up in Access query

Posted on 2011-03-11
4
271 Views
Last Modified: 2012-05-11
Hello,

I need a query that takes a price and rounds UP to the next 5p, i.e £2.36 should go to £2.40 and £5.12 should go to £5.15 etc.

Thanks
0
Comment
Question by:Petermcg001
  • 2
4 Comments
 
LVL 6

Expert Comment

by:zane_o
ID: 35109202
Rounding to 5p is done by multiplying the number by 20, rounding it, and dividing by 20 to get to the proper value.
    Round(20 * [Amount], 0) / 20
0
 
LVL 29

Expert Comment

by:Randy Downs
ID: 35109211
Try this - http://allenbrowne.com/round.html

Rounding up
To round upwards towards the next highest number, take advantage of the way Int() rounds negative numbers downwards, like this:
    - Int( - [MyField])

As shown above, Int(-2.1) rounds down to -3. Therefore this expression rounds 2.1 up to 3.

To round up to the higher cent, multiply by -100, round, and divide by -100:
    Int(-100 * [MyField]) / -100
0
 
LVL 6

Accepted Solution

by:
zane_o earned 500 total points
ID: 35109286
Missed the always round up part. If you combine the two responses here, you get something like:
 Int(-20 * [Amount]) / -20
0
 
LVL 1

Author Comment

by:Petermcg001
ID: 35109524
Thanks for looking at this.  zane o's solution works perfectly.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now