Thanks for that code. I'm going to make that my next assignment. I decided to change the names of the toggles and went with the code below. No sure if there is excess. Could I be more streamline?
Code:
Private Sub cmdDisplay_Click()
Dim ctl As Control
Dim Ball(1 To 5) As Integer
Dim Count As Integer
Dim togCount As Integer
togCount = 0
Count = 1
On Error GoTo tomanyBalls
For Each ctl In Me.Controls
If ctl.ControlType = acToggleButton Then
togCount = togCount + 1
If ctl.Value = True Then
Ball(Count) = togCount
Count = Count + 1
End If
End If
Next
'ball1, ball2, etc.. are the names of the text boxes on the form that display the numbers
Ball1 = Ball(1)
Ball2 = Ball(2)
Ball3 = Ball(3)
Ball4 = Ball(4)
Ball5 = Ball(5)
txtNumMatches = findMatch()
If txtNumMatches > 0 Then
txtNumMatches.Visible = True
Else
txtNumMatches.Visible = False
End If
If Ball1 = 0 Or Ball2 = 0 Or Ball4 = 0 Or Ball5 = 0 Then
MsgBox "Select more numbers"
End If
Exit Sub
tomanyBalls: MsgBox "Too many numbers"
End Sub