title: How to loop through CheckBoxes on UserForm?
body: <p>By selecting an OptionButton I want all CheckBoxes on the active form to deselect AND UNCHECK.</p>
  
  <p>I can get it to deselect using the For Each Loop but this does not work for unchecking the boxes. I get the error:</p>
  
  <blockquote>
    <p>chB.Value=Object variable or With block variable not set</p>
  </blockquote>
  
  <pre><code>Private Sub optB_9201_Click()
  
  Dim ctrl As Control
  Dim chB As CheckBox
  
  If Me.optB_9201.Value = True _
    And Me.optB_9251.Value = False _
    And Me.optB_9301.Value = False Then
  
      Me.img9301_main.Visible = True
      Me.frM9301_View.Caption = "Du har valgt CLX-9201NA med følgende konfigurasjon:"
      Me.frm9301_Equipment.Enabled = True
  
      For Each ctrl In Me.frm9301_Equipment.Controls
          ctrl.Enabled = False
          chB.Value = False
      Next ctrl
  
      Me.frM9301_Stand.Enabled = True
  
      For Each ctrl In Me.frM9301_Stand.Controls
          ctrl.Enabled = True
      Next ctrl
  
  End If
  
  End Sub
  </code></pre>
  
  <p>How to fix this?</p>
  
  <p>Alternatively:</p>
  
  <p>Is is possible to have a change event on the UserForm that states that if a CheckBox is Enabled= False Then Value=False.</p>
  
  <p>This way I would not have to put in the For Each Loop on every OptionButton. I tried the UserForm_Change Sub and UserForm_Click but nothing seems to work.</p>