A
Ayo
I have a problem and I hope someone can help with it. I have a form with a
bunch of Checkboxes. And I have 3 Option buttons: Select All, Make Selection
and Clear All, and 2 buttons. The buttons are disabled. Slect All checks all
the CheckBoxes and enable the buttons, Clear All uncheck all the CheckBoxes
and disable the buttons.
Make Selection is surposed to uncheck all the CheckBoxes with the buttons
still disabled. What I want to do next is this, any time a checkbox is
checked I want the 2 buttons to become enabled and if no checkbox is checked
I want the 2 buttons to be disabled.
I have tried the codes below, the Sub frmSelectMilestones_Click() works
fine but I still can't figire out how to enable the 2 buttons when at least
one checkbox is checked.
Any help will be greatly appreciated. Thanks.
Private Sub Form_Current()
Dim ctrl As Control, counter As Integer
Dim frm As Form
Set frm = Me.Form
counter = 0
For Each ctrl In frm.Controls
With ctrl
Select Case .ControlType
Case acCheckBox
If .Value = True Then
counter = counter + 1
End If
End Select
End With
Next ctrl
If counter >= 1 Then
Me.cmdRunAQuery.Enabled = True
Me.cmdRunOQuery.Enabled = True
ElseIf counter = 0 Then
Me.cmdRunAQuery.Enabled = False
Me.cmdRunOQuery.Enabled = False
End If
End Sub
Private Sub frmSelectMilestones_Click()
Dim counter As Integer
Dim ctrl As Control
Dim frm As Form
Set frm = Me.Form
counter = 0
Select Case frmSelectMilestones
Case 1
For Each ctrl In frm.Controls
With ctrl
Select Case .ControlType
Case acCheckBox
.Enabled = True
.Value = True
End Select
End With
Next ctrl
Me.cmdRunAQuery.Enabled = True
Me.cmdRunOQuery.Enabled = True
Case 2
For Each ctrl In frm.Controls
With ctrl
Select Case .ControlType
Case acCheckBox
.Enabled = True
.Value = False
End Select
End With
Next ctrl
Case 3
For Each ctrl In frm.Controls
With ctrl
Select Case .ControlType
Case acCheckBox
.Value = False
'.Enabled = False
End Select
End With
Next ctrl
Me.cmdRunAQuery.Enabled = False
Me.cmdRunOQuery.Enabled = False
End Select
End Sub
bunch of Checkboxes. And I have 3 Option buttons: Select All, Make Selection
and Clear All, and 2 buttons. The buttons are disabled. Slect All checks all
the CheckBoxes and enable the buttons, Clear All uncheck all the CheckBoxes
and disable the buttons.
Make Selection is surposed to uncheck all the CheckBoxes with the buttons
still disabled. What I want to do next is this, any time a checkbox is
checked I want the 2 buttons to become enabled and if no checkbox is checked
I want the 2 buttons to be disabled.
I have tried the codes below, the Sub frmSelectMilestones_Click() works
fine but I still can't figire out how to enable the 2 buttons when at least
one checkbox is checked.
Any help will be greatly appreciated. Thanks.
Private Sub Form_Current()
Dim ctrl As Control, counter As Integer
Dim frm As Form
Set frm = Me.Form
counter = 0
For Each ctrl In frm.Controls
With ctrl
Select Case .ControlType
Case acCheckBox
If .Value = True Then
counter = counter + 1
End If
End Select
End With
Next ctrl
If counter >= 1 Then
Me.cmdRunAQuery.Enabled = True
Me.cmdRunOQuery.Enabled = True
ElseIf counter = 0 Then
Me.cmdRunAQuery.Enabled = False
Me.cmdRunOQuery.Enabled = False
End If
End Sub
Private Sub frmSelectMilestones_Click()
Dim counter As Integer
Dim ctrl As Control
Dim frm As Form
Set frm = Me.Form
counter = 0
Select Case frmSelectMilestones
Case 1
For Each ctrl In frm.Controls
With ctrl
Select Case .ControlType
Case acCheckBox
.Enabled = True
.Value = True
End Select
End With
Next ctrl
Me.cmdRunAQuery.Enabled = True
Me.cmdRunOQuery.Enabled = True
Case 2
For Each ctrl In frm.Controls
With ctrl
Select Case .ControlType
Case acCheckBox
.Enabled = True
.Value = False
End Select
End With
Next ctrl
Case 3
For Each ctrl In frm.Controls
With ctrl
Select Case .ControlType
Case acCheckBox
.Value = False
'.Enabled = False
End Select
End With
Next ctrl
Me.cmdRunAQuery.Enabled = False
Me.cmdRunOQuery.Enabled = False
End Select
End Sub