Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Access
3rdpartyusrgrp
access
activexcontrol
adp.sqlserver
commandbarsui
conversion
dataaccess.pages
developers.toolkitode
devtoolkits
externaldata
forms
formscoding
gettingstarted
internet
interopoledde
macros
modulescoding
modulesdaovba
modulesdaovba.ado
multiuser
odbcclientsvr
queries
replication
reports
security
setupconfig
tablesdbdesign
  
 
date: Mon, 13 Oct 2008 15:54:20 -0500,    group: microsoft.public.access.queries        back       


Round to 100   
Hi,

I would like to round a number to hundreadth like this
100 -> 100
101 -> 200
150 -> 200
199 -> 200
200 -> 200

What is the best way to qrite a query to do this?

Thanks,
Boon
date: Mon, 13 Oct 2008 15:54:20 -0500   author:   Boon

Re: Round to 100   
roundedvalue: IIf([numberfield]>CInt(Left([numberfield],1) &
"00"),CInt(Left([numberfield],1) & "00")+100,IIf([numberfield]<100,100,
[numberfield]))

as a note this will only work with values up to 899

i dont know of a rounding function in access as i am using access 97
someone else may know though

Regards
Kelvan
date: Mon, 13 Oct 2008 14:29:44 -0700 (PDT)   author:   Lord Kelvan

Re: Round to 100   
On Mon, 13 Oct 2008 15:54:20 -0500, "Boon" 
wrote:

>Hi,
>
>I would like to round a number to hundreadth like this
>100 -> 100
>101 -> 200
>150 -> 200
>199 -> 200
>200 -> 200
>
>What is the best way to qrite a query to do this?
>
>Thanks,
>Boon
>

If the field is named Num, a calculated field

-Int(-[Num]/100)*100

will do it for you. Int rounds down (or truncates), so taking Int of the
negative and then taking the negative of *that* rounds up.
-- 

             John W. Vinson [MVP]
date: Mon, 13 Oct 2008 16:32:27 -0600   author:   John W. Vinson

Re: Round to 100   
Here's a resource that explains various ways to round data in Access:
    http://allenbrowne.com/round.html#RoundUp
The 'Rounding up' section describes what you need.

Don't forget to consider what you want with negatives, e.g. should -99 be 
rounded 'up' to 0? Or should -1 be rounded 'down' to -100?

-- 
Allen Browne - Microsoft MVP.  Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Boon"  wrote in message
news:OreZvXXLJHA.4452@TK2MSFTNGP05.phx.gbl...
> Hi,
>
> I would like to round a number to hundreadth like this
> 100 -> 100
> 101 -> 200
> 150 -> 200
> 199 -> 200
> 200 -> 200
>
> What is the best way to qrite a query to do this?
date: Tue, 14 Oct 2008 11:00:00 +0800   author:   Allen Browne lid

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us