Round in a macro

  • Thread starter Thread starter Rob
  • Start date Start date
R

Rob

Using an action of SetValue,
Item is; [SLJ Points],
Expression is; Round([Standing Long Jump],0)

When used and shown in my form,
result on an "odd number.5" rounds up to "next even number"
and on a "even number.5" rounds down to the even number".

Rounding on a "number.5" is supposed to always go up (if my
memory serves me correctly).

What should I do to correct this?

This is for a sports scoring database I am working on. I
need to set the scores based on the results of the sport
event. I am still wondering how to handle a tie.

Rob
 
Introduce a very small BiasMargin into your expression. For example, if you
only work with one or 2 decimal places, you can use 0.001.

From A2K Debug window:

BiasMargin = 0.001
?Round(1.49 + BiasMargin)
1

?Round(1.50 + BiasMargin)
2

For the record, there is no official version for rounding of exactly half
the interval. When I studied HS, we always rounded down the 0.5. Access
uses Banker's Rounding (nearest event). For some other purposes, rounding
UP of 0.5 is more suitable.

There is a Microsoft Knowledge Base article on rounding you should have a
look:

http://support.microsoft.com/?id=196652
 
Wow, that MKB article is very detailed.

So, given that the values will be to the nearest tenth (under normal
conditions) in the event results field, I can not use my macro to round
that number for the entry into the score field unless the results field
had the bias added to it. Which would make the expression something
like "Round([Standing Long Jump]+bias,0)"

Thanks, it helped.


Introduce a very small BiasMargin into your expression. For example, if you
only work with one or 2 decimal places, you can use 0.001.

From A2K Debug window:

BiasMargin = 0.001
?Round(1.49 + BiasMargin)
1

?Round(1.50 + BiasMargin)
2

For the record, there is no official version for rounding of exactly half
the interval. When I studied HS, we always rounded down the 0.5. Access
uses Banker's Rounding (nearest event). For some other purposes, rounding
UP of 0.5 is more suitable.

There is a Microsoft Knowledge Base article on rounding you should have a
look:

http://support.microsoft.com/?id=196652

--
HTH
Van T. Dinh
MVP (Access)



Using an action of SetValue,
Item is; [SLJ Points],
Expression is; Round([Standing Long Jump],0)

When used and shown in my form,
result on an "odd number.5" rounds up to "next even number"
and on a "even number.5" rounds down to the even number".

Rounding on a "number.5" is supposed to always go up (if my
memory serves me correctly).

What should I do to correct this?

This is for a sports scoring database I am working on. I
need to set the scores based on the results of the sport
event. I am still wondering how to handle a tie.

Rob
 
So your accuracy is only 1 decimal place.

Instead of the normal:

Round([Standing Long Jump],0)

use

Round([Standing Long Jump]+0.01,0)

With the second expression, the .4 becomes .41 and (still) gets rounded
down. The .5 becomes .51 and will get rounded UP all the time!
 
Back
Top