Hi
I have a button which loops through the controls on my form and sets the Checkboxes to true.
I would like to modify this button so it serves as a toggle feature - ie; set all the Checkboxes = True if they are False, and set all the Checkboxes = False if they are True.
Private Sub CommandButton1_Click()
Dim oCtrl As Control
For Each oCtrl In Me.Controls
If TypeOf oCtrl Is msforms.CheckBox Then
oCtrl.Value = True
End If
Next
End Sub
I tried modifying the above to code to below but it's giving an error, seems like it doesn't like the "oCtrl.Value = False And" part...?
Private Sub CommandButton1_Click()
Dim oCtrl As Control
For Each oCtrl In Me.Controls
If oCtrl.Value = False And TypeOf oCtrl Is msforms.CheckBox Then
oCtrl.Value = True
End If
If oCtrl.Value = True And TypeOf oCtrl Is msforms.CheckBox Then
oCtrl.Value = False
End If
Next
End Sub
Appreciate any input!
Thanks
Fergal
Bookmarks