Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rounding

Status
Not open for further replies.

cranebill

IS-IT--Management
Jan 4, 2002
1,113
0
0
US
Does anyone know of a simple way to possibly round up to the nearest 2? I can do it in Excel but have yet to find a way to do it in Access... for example

1.1=2

1.9 = 2

27.6 = 28

I guess rounding up to an even integer may work but still do not know how to do that.

Any help appreciated.

Bill
 
try this function. I wrote it to round to mine specs, but i've amended it for yours:

Public Function Round(TQ As Variant) As Double
Dim A, B, C As Double

A = TQ - Int(TQ)
If A = 0 Then
B = 0
Else
B = 1
End If
C = B + Int(TQ)

Round = C
End Function
 
Thanx for the help... I had to modify it a tad. I was using test data and for some reason it sometimes would go to an odd number so I added .5 and it seems to be working well. Here is the way i modified it:

Private Sub Command243_Click()
Dim A, B, C As Double
Dim TQ As Double
TQ = 60.1

A = TQ - Int(TQ)
If A = 0 Then
B = 0
Else
B = 1
End If
C = B + Int(TQ)
C = Round(C + 0.5)


MsgBox C, , test
End Sub

Can you tell me though what does this function you wrote do:

Int(TQ)

Thanx again,

Bill



 
int(x) strips x of it's decimal data, so int(5.67) = 5

i coded it round to .5 as well if required, but you can amend as required
 
2*(int(x)/2+1)


- may seeds of dreams fall from my hands
and by yours be pressed into the ground
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top