Round a number/ Access 2007

  • Thread starter Thread starter Abay
  • Start date Start date
A

Abay

Hello,

I am trying to round the results of a calculation without success.

I would like the result of the following to round up to 2 decimal places.

Dgst - dlinetot / 105 * 5

Dgst is defined as a number with 2 decimal places
Dlinetot is defined as a number with 3 decimal places

The result should be 4.67 but shows 4.66

I tried using the Round function (using the sytax from access help),as
follows:

round (dgst = dlinetot / 105 * 5 [,2]) or
round (dgst=dlinetot/105 * 5, 2) and get an error msg "expected end of
statement"

I know I am doing something wrong .. so any help with this would be most
appreciated.

Abay
 
Abay said:
Hello,

I am trying to round the results of a calculation without success.

I would like the result of the following to round up to 2 decimal places.

Dgst - dlinetot / 105 * 5

Dgst is defined as a number with 2 decimal places
Dlinetot is defined as a number with 3 decimal places

The result should be 4.67 but shows 4.66

I tried using the Round function (using the sytax from access help),as
follows:

round (dgst = dlinetot / 105 * 5 [,2]) or
round (dgst=dlinetot/105 * 5, 2) and get an error msg "expected end of
statement"

I know I am doing something wrong .. so any help with this would be most
appreciated.

Abay

Your 2nd try with the round function almost had it. Try:

dgst = round(dlinetot/105 * 5, 2)

This assigns the result from the round function to dgst.
 
Dgst - dlinetot / 105 * 5

Dgst is defined as a number with 2 decimal places
Dlinetot is defined as a number with 3 decimal places

The result should be 4.67 but shows 4.66

4.66 is correct; Access uses "Banker's Rounding". A value ending in 5 will
round to the nearest *even* number, up or down, rather than always rounding
up; this gives a more accurate result, since the average of a large set of
numbers will be closer to the average of the same set, rounded. The "rounding
up" algorithm will make the results creep up.
 
Many thanks Stuart ... it works of course, yeah!
Really appreciate your help.

Abay


Stuart McCall said:
Abay said:
Hello,

I am trying to round the results of a calculation without success.

I would like the result of the following to round up to 2 decimal places.

Dgst - dlinetot / 105 * 5

Dgst is defined as a number with 2 decimal places
Dlinetot is defined as a number with 3 decimal places

The result should be 4.67 but shows 4.66

I tried using the Round function (using the sytax from access help),as
follows:

round (dgst = dlinetot / 105 * 5 [,2]) or
round (dgst=dlinetot/105 * 5, 2) and get an error msg "expected end of
statement"

I know I am doing something wrong .. so any help with this would be most
appreciated.

Abay

Your 2nd try with the round function almost had it. Try:

dgst = round(dlinetot/105 * 5, 2)

This assigns the result from the round function to dgst.
 
Back
Top