Rounding up all odd numbers

T

TROUBLED

Can someone please explain to me what I need to do to get it so when my users
are entering an item into a form and it is an odd number to automatically
round that number up so it is even. I only want odd numbers to round. If an
even is input, I need to to stay as is.

Any help would be great!
 
D

Dirk Goldgar

TROUBLED said:
Can someone please explain to me what I need to do to get it so when
my users are entering an item into a form and it is an odd number to
automatically round that number up so it is even. I only want odd
numbers to round. If an even is input, I need to to stay as is.

Any help would be great!

Are you talking about "rounding up" whole numbers, so that odd numbers
such as 1, 3, 5 are always adjusted to the next higher number, such as
2, 4, 6? If so, you could use code in the AfterUpdate event of the text
box where the number is entered. For example:

'----- start of example code -----
Private Sub TheNumber_AfterUpdate()

With Me.TheNumber
.Value = .Value + (.Value Mod 2)
End With

End Sub
'----- end of example code -----
 
Top