A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

round numbers so the total is divisible by 5



 
 
Thread Tools Display Modes
  #1  
Old January 8th, 2005, 12:37 PM
Jeannie S
external usenet poster
 
Posts: n/a
Default round numbers so the total is divisible by 5

HI
I have the round function set with 2 decimal places on a currenty field in
an Access table. This field calculates quantity x cost. The cost of an item
could be below $1.00. The quantity could be a whole number (1) or a part of
a whole (.5, 1.3). I need to have the calculation round up to the nearest
number divisible by 5. Ex: 1 x $ .75 should equal $ .75, but my total
calculates as $ .80. If the number is already divisible by 5, I don't want
the number to round up. Other examples a 1.2 x $ .20 ($ .24) should round
to $ .25 OR 1.7 x $ .20 ($ .34) should round to $ .35 OR 1.3 x $ .20 ($ .26)
should round to $ .30.
I don't know anything about writing "code". I do my designing for
calculations only using queries, controls on forms or reports, and macros. I
have played a tiny bit with the modules, but I really don't know what I am
doing in that area.
Can anyone advise me on this rounding issue? Thanks so much.
  #2  
Old January 8th, 2005, 02:03 PM
Van T. Dinh
external usenet poster
 
Posts: n/a
Default

CInt(Qty * Price * 20) / 20

should do what you want. For example (from the Debug window):

?CInt(1.2 * 0.2 * 20) / 20
0.25


--
HTH
Van T. Dinh
MVP (Access)


"Jeannie S" wrote in message
news
HI
I have the round function set with 2 decimal places on a currenty field in
an Access table. This field calculates quantity x cost. The cost of an

item
could be below $1.00. The quantity could be a whole number (1) or a part

of
a whole (.5, 1.3). I need to have the calculation round up to the nearest
number divisible by 5. Ex: 1 x $ .75 should equal $ .75, but my total
calculates as $ .80. If the number is already divisible by 5, I don't

want
the number to round up. Other examples a 1.2 x $ .20 ($ .24) should

round
to $ .25 OR 1.7 x $ .20 ($ .34) should round to $ .35 OR 1.3 x $ .20 ($

..26)
should round to $ .30.
I don't know anything about writing "code". I do my designing for
calculations only using queries, controls on forms or reports, and macros.

I
have played a tiny bit with the modules, but I really don't know what I am
doing in that area.
Can anyone advise me on this rounding issue? Thanks so much.



  #3  
Old January 8th, 2005, 05:21 PM
Tim Ferguson
external usenet poster
 
Posts: n/a
Default

=?Utf-8?B?SmVhbm5pZSBT?= wrote in
news
The quantity could be a whole number (1) or a part of
a whole (.5, 1.3). I need to have the calculation round up to the
nearest number divisible by 5.


Iif(5*Int(Amount/5)=Amount, Amount, 5+5*Int(Amount/5))

You can put this is the controlsource of a control on a form or report, or
in the calculation part of the query grid (unless you are working in adp &
SQL server, probably).

If you want to change the rounding to 5 cents (rather than 5 dollars),
which seems to be sense of your original post, then change all the fives to
0.05


Hope that helps


Tim F

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I identify different numbers to a table of numbers Erich Niemand Worksheet Functions 1 September 9th, 2004 04:25 AM
formulas for round numbers up to next dolllar dewberryz General Discussion 2 August 13th, 2004 02:45 PM
Round Up Numbers to Nearest 500 Agnes Worksheet Functions 1 June 24th, 2004 01:58 AM
How to round currency values to a number divisible by another number? Eric Worksheet Functions 2 March 10th, 2004 02:41 AM


All times are GMT +1. The time now is 03:15 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.