Getting A Running Count of Checked Check Boxes

  1. Enter Dim ItemsChecked As Integer in the General (Declarations) section of the form where the checked boxes are located.
  2. 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:

  1. In the Form_Load event enter x.Enabled = False where X is the name of the command button.
  2. 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.
  3. 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.

Contact Me

Access

Access

Home

Home

Links

Links

Miscellaneous

Other

Programs By Me

Programs

Visual Basic

Visual Basic

Windows

Windows