Getting A Running Count of Checked Check Boxes
- Enter Dim ItemsChecked As Integer in the General (Declarations) section of the form where the checked boxes are located.
- In the Click event for each check box enter
If X.Value = vbChecked Then
ItemsChecked = ItemsChecked + 1
Else
ItemsChecked = ItemsChecked - 1
End If
where X is the name of the check
box.
You can use this count to have a command button disabled when no boxes are checked if at least one must be checked for the code in the command button’s Click event to run properly. Just follow these steps:
- In the Form_Load event enter x.Enabled = False where X is the name of the command button.
- In the Click event for each check box enter x.Enabled = True where X is the name of the command button below the line above that starts with If.
- In the Click event for each check box enter
If ItemsChecked = 0 Then
X.Enabled = False
End If
where X is the name of the command button below the above code.
Lila Godel's Web Site
Brought To You By Hamilton Services, Inc.