PDA

View Full Version : if odd number of checkboxes selected- Warning!



satyen
02-08-2010, 11:59 AM
I've found this piece of code but cant seem to fix it to do what I would like.
Basically in MS Access I have a form. If user selects 3 items- this is wrong. Even 5 items is wrong. They should always select an equal amount. (even no. of check boxes) otherwise it should give a warning and Exit Sub.

Can anyone help?


Public Function IsEven(ByVal Number As Long) As Boolean
IsEven = (Number Mod 2 = 0)
End Function

Function IsOdd(x As Integer) As Boolean
IsOdd = (x Mod 2)<>0
End Function

Sub Test()
For i = 1 To 10
If IsOdd(i) Then
Msgbox i & " is odd"
End If
Next i
End Sub

OBP
02-08-2010, 02:00 PM
Try
If IsOdd(i)= 1 Then