I'm new to access and trying to round to the nearest quarter. ie. 1.4 = 1.5, 1.1=1.25, 1.6=1.75, 1.9=2.0
I wrote the following module but something is wrong?
Option Compare Database
Function qtrround(interval)
Dim wholenumber As Long, fracnumber As Long
wholenumber = Int(interval)
fracnumber = (interval) - wholenumber
If fracnumber > (7 / 60) Then fracnumber = (0.25)
If fracnumber > (22 / 60) Then fracnumber = (0.5)
If fracnumber > (37 / 60) Then fracnumber = (0.75)
If fracnumber > (52 / 60) Then fracnumber = (1)
end if
qtrround = (wholenumber + fracnumber)
End Function
I want to be able to type ControlSource: =qtrround([interval]) and get the number to round to the nearest qtr.
Where am I going wrong here?
Thanks
I wrote the following module but something is wrong?
Option Compare Database
Function qtrround(interval)
Dim wholenumber As Long, fracnumber As Long
wholenumber = Int(interval)
fracnumber = (interval) - wholenumber
If fracnumber > (7 / 60) Then fracnumber = (0.25)
If fracnumber > (22 / 60) Then fracnumber = (0.5)
If fracnumber > (37 / 60) Then fracnumber = (0.75)
If fracnumber > (52 / 60) Then fracnumber = (1)
end if
qtrround = (wholenumber + fracnumber)
End Function
I want to be able to type ControlSource: =qtrround([interval]) and get the number to round to the nearest qtr.
Where am I going wrong here?
Thanks