I'm fairly new at this (VBA programming) so pls forgive me if my coding seems simplistic.
I have a Word UserForm (Word 2007) with some checkboxes and 2 command controls - Ok and Cancel. When the form is activated from the macro menu or from an assigned icon the checkboxes don't work. However, the 2 command controls work.
What I mean by not working is that when I click on the checkboxes nothing happen - they don't respond. When I click on the OK button a message appears telling me that I haven't selected anything! When I click on the Cancel button the form unloads.
The checkboxes consist of the Click event which toggles from checked to uncheck. There's also a SelectAll checkbox. When clicked all the other checkboxes are checked or uncheck. When one of the other checkbox is uncheck the SelectAll checkbox is also uncheck.
When I activate the form from VBE everything works exactly the way I want them to.
Here's a sample of what I'm talking about:
Sub Loadform()
Load UserForm1
UserForm1.Show
End Sub
Private Sub btnCancel_Click()
Unload Me
End Sub
Private Sub btnOK_Click()
If Me.CheckBox2.Value = True And Me.CheckBox3.Value = True Then
MsgBox "All checkboxes are checked"
ElseIf Me.CheckBox2.Value = True Then
MsgBox Me.CheckBox2.Name & " is checked"
ElseIf Me.CheckBox3.Value = True Then
MsgBox Me.CheckBox3.Name & " is checked"
ElseIf Me.CheckBox2.Value = False And Me.CheckBox3.Value = False Then
MsgBox "You haven't selected any checkboxes."
End If
End Sub
Private Sub CheckBox2_Click()
If Me.CheckBox2.Value = True Then
Me.CheckBox2.Value = False
Me.ckbSelectAll.Value = False
Else
Me.CheckBox2.Value = True
End If
End Sub
Private Sub CheckBox3_Click()
If Me.CheckBox3.Value = True Then
Me.CheckBox3.Value = False
Me.ckbSelectAll.Value = False
Else
Me.CheckBox3.Value = True
End If
End Sub
Private Sub ckbSelectAll_Click()
If Me.ckbSelectAll.Value = True Then
Me.ckbSelectAll.Value = False
Else
Me.ckbSelectAll.Value = True
End If
If ckbSelectAll.Value = False Then
Me.CheckBox2.Value = False
Me.CheckBox3.Value = False
Else
Me.CheckBox2.Value = True
Me.CheckBox3.Value = True
End If
End Sub
I've been looking at this code for so long and I still can't find where the problem is. Any assistance in solving this problem is greatly appreciated.