This works great - Thanks. The ratio it is returning is in the following
format 8.04545454545455:1 - is there a way to have this ready 8:1 - i
tried playing around with the decimal places setting in the control butit
doesn't seem to have any effect.
You could use the Round() function to round the result of the division to
any desired number of decimal places. If you want to allow up to 1 decimal
place, you could use this expression:
=IIf([Field2]=0 Or [Field1] Is Null Or [Field2] Is
Null,Null,Round([Field1]/[Field2], 1) & ":1")
If you always want to round to a whole number, you could write this:
=IIf([Field2]=0 Or [Field1] Is Null Or [Field2] Is
Null,Null,Round([Field1]/[Field2], 0) & ":1")
You should be aware that the Round() function in Access uses "bankers
rounding", which tries to even out the effects of rounding error by rounding
a trailing digit 5 up if the preceding digit is odd, down if the preceding
digit is even. This isn't the same as the rounding most of us were taught
in school, where we always round 5 up. Here's an example from the immediate
window:
For x = 0.5 to 5.5 : ?x; " rounds to "; Round(x, 0) : next x
0.5 rounds to 0
1.5 rounds to 2
2.5 rounds to 2
3.5 rounds to 4
4.5 rounds to 4
5.5 rounds to 6
Note that this only matters when the digit being rounded off is 5.
If you don't want banker's rounding, you can write your own function, or get
one from (for example) here:
http://www.mvps.org/access/modules/mdl0054.htm
Modules: Implementing a custom Rounding procedure