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
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
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]
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?