D
Debbiedo
I have a command button that selects/deselect all check boxes on a
form.
The problem is when I click it after opening and nothing has been
selected yet (we are at a new record), it selects all but the first
check box and when I click again, it selects the first check box and
deselects the rest.
Also, if even one of the check boxes is checked and then I click the
command button, not all the check boxes are selected, only the ones
not selected prior to clicking. The one(s) that were selected are now
deselected. So it is not a true "Select All Check Boxes" command.
I have five check boxes. The user can select any number of boxes. In
most cases they will be selecting all 5, which is why I want a "select
all" button.
What am I doing wrong? None of my other code refers to the check
boxes. All the properties for the check boxes are the same (except for
the Name, etc.)
Below is my code. I am using Access 2003
Private Sub Command24_Click()
Dim ctl As Control
For Each ctl In Me.Controls
' Check to see if control is check box.
If ctl.ControlType = acCheckBox Then
If ctl.Value = False Then
ctl.Value = True
Else
ctl.Value = False
End If
End If
Next ctl
End Sub
Thanks
Deb
form.
The problem is when I click it after opening and nothing has been
selected yet (we are at a new record), it selects all but the first
check box and when I click again, it selects the first check box and
deselects the rest.
Also, if even one of the check boxes is checked and then I click the
command button, not all the check boxes are selected, only the ones
not selected prior to clicking. The one(s) that were selected are now
deselected. So it is not a true "Select All Check Boxes" command.
I have five check boxes. The user can select any number of boxes. In
most cases they will be selecting all 5, which is why I want a "select
all" button.
What am I doing wrong? None of my other code refers to the check
boxes. All the properties for the check boxes are the same (except for
the Name, etc.)
Below is my code. I am using Access 2003
Private Sub Command24_Click()
Dim ctl As Control
For Each ctl In Me.Controls
' Check to see if control is check box.
If ctl.ControlType = acCheckBox Then
If ctl.Value = False Then
ctl.Value = True
Else
ctl.Value = False
End If
End If
Next ctl
End Sub
Thanks
Deb