I have a list of states on a form, in which the user can click on various states that are applicable to the form. There is a "ALL State" option (CheckBoxALL) in which if selected all of the state checkboxes will be checked. Below is the following code:
Private Sub CheckBoxALL_Cli ck()
If CheckBoxAll = True Then
CheckBoxState01 = True
CheckBoxState02 = True
CheckBoxState03 = True
CheckBoxState04 = True
etc.....
CheckBoxState52 = True
Else
CheckBoxState01 = False
CheckBoxState02 = False
CheckBoxState03 = False
CheckBoxState04 = False
CheckBoxState05 = False
CheckBoxState06 = False
etc.........Che ckBoxState52 = False
End If
End Sub
_______________ ________
My question is if there is a cleaner way to write this code than the way I wrote it since I am still in VBA learning mode?
I tried something like this but it keeps error out:
Private Sub CheckBoxALL_Cli ck()
Dim CheckALL As Boolean
Set CheckALL = ActiveDocument. FormFields("Che ckBoxALL").Chec kBox.Value
If CheckALL("Check BoxALL").CheckB ox.Value = True Then
For i = 1 To 52
CheckALL("Check BoxState0" & i).CheckBox.Val ue = True
Next i
Else
For i = 1 To 52
CheckALL("Check BoxState0" & i).CheckBox.Val ue = False
Next i
End If
End Sub
_______________ __
My result so far has been compile errors and coding that does not work. Does anybody have any ideas??
Thanks,
Keith.
Private Sub CheckBoxALL_Cli ck()
If CheckBoxAll = True Then
CheckBoxState01 = True
CheckBoxState02 = True
CheckBoxState03 = True
CheckBoxState04 = True
etc.....
CheckBoxState52 = True
Else
CheckBoxState01 = False
CheckBoxState02 = False
CheckBoxState03 = False
CheckBoxState04 = False
CheckBoxState05 = False
CheckBoxState06 = False
etc.........Che ckBoxState52 = False
End If
End Sub
_______________ ________
My question is if there is a cleaner way to write this code than the way I wrote it since I am still in VBA learning mode?
I tried something like this but it keeps error out:
Private Sub CheckBoxALL_Cli ck()
Dim CheckALL As Boolean
Set CheckALL = ActiveDocument. FormFields("Che ckBoxALL").Chec kBox.Value
If CheckALL("Check BoxALL").CheckB ox.Value = True Then
For i = 1 To 52
CheckALL("Check BoxState0" & i).CheckBox.Val ue = True
Next i
Else
For i = 1 To 52
CheckALL("Check BoxState0" & i).CheckBox.Val ue = False
Next i
End If
End Sub
_______________ __
My result so far has been compile errors and coding that does not work. Does anybody have any ideas??
Thanks,
Keith.
Comment