Solved

Rounding up in Access query

Posted on 2011-03-11
4
278 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 30

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

732 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