Alex Rivera | Logout

Rounding in MS Access

Asked 2008-09-26T00:30:29.713
14

Whats the best way to round in VBA Access?

My current method utilizes the Excel method

Excel.WorksheetFunction.Round(...

But I am looking for a means that does not rely on Excel.

Edit
Report

2 Answers

1

If you're talking about rounding to an integer value (and not rounding to n decimal places), there's always the old school way:

return int(var + 0.5)

(You can make this work for n decimal places too, but it starts to get a bit messy)

answered 2008-09-26T01:09:37.903
0

Here is easy way to always round up to next whole number in Access 2003:

BillWt = IIf([Weight]-Int([Weight])=0,[Weight],Int([Weight])+1)

For example:

  • [Weight] = 5.33 ; Int([Weight]) = 5 ; so 5.33-5 = 0.33 (<>0), so answer is BillWt = 5+1 = 6.
  • [Weight] = 6.000, Int([Weight]) = 6 , so 6.000-6 = 0, so answer is BillWt = 6.
answered 2009-12-30T16:35:06.973

Your Answer