Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
userform command button checkbox problem
Hi
I am new to this list, but would appreciate any help available. I have userrform with several clusters of checkboxes and for each cluster a command button that allows the user to select or deselect all the check boxes in a cluster, using code typically as follows: Private Sub cmdSelAllStages_Click() ' select / deselect all stages, if any stage is false make them all true, ' else make all stages false If chkPPM0 = False Or chkPPM1 = False Or chkPPM2 = False Or chkPPM3 = False Then chkPPM0 = True chkPPM1 = True chkPPM2 = True chkPPM3 = True Else chkPPM0 = False chkPPM1 = False chkPPM2 = False chkPPM3 = False End If . . . . . . . . End Sub Each checkbox has a worksheet cell set as its 'controlsource' property to store its current value. Problem is that when the userform is displayed and one, some or all of the cluster of checkboxes is false then, when the command button is clicked as the first action, the code only makes the first checkbox in the cluster true (or the first checkbox in the cluster that is false, true) instead of, as I want, making all the checkboxes true if any of them are false. The reverse is also true - if all boxes are true when command button is clicked it makes only the first box untrue, rather than making all of them untrue. The command buttons work fine on any subsequent occassion when the command button is clicked - it is just when it is the first action on using the userform that the problem occurs! Can anyone explain this or provide a fix for it? Any help much appreciated, its got me baffled. Mike |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
userform command button checkbox problem
Mike,
Checkboxes can have a Null value as well as True or False. I suspect that you did not set the values for the boxes during the design of the form. However, try changing "= False" to "< True" -- Jim Cone San Francisco, USA http://www.realezsites.com/bus/primitivesoftware wrote in message Hi I am new to this list, but would appreciate any help available. I have userrform with several clusters of checkboxes and for each cluster a command button that allows the user to select or deselect all the check boxes in a cluster, using code typically as follows: Private Sub cmdSelAllStages_Click() ' select / deselect all stages, if any stage is false make them all true, ' else make all stages false If chkPPM0 = False Or chkPPM1 = False Or chkPPM2 = False Or chkPPM3 = False Then chkPPM0 = True chkPPM1 = True chkPPM2 = True chkPPM3 = True Else chkPPM0 = False chkPPM1 = False chkPPM2 = False chkPPM3 = False End If . . . . . . . . End Sub Each checkbox has a worksheet cell set as its 'controlsource' property to store its current value. Problem is that when the userform is displayed and one, some or all of the cluster of checkboxes is false then, when the command button is clicked as the first action, the code only makes the first checkbox in the cluster true (or the first checkbox in the cluster that is false, true) instead of, as I want, making all the checkboxes true if any of them are false. The reverse is also true - if all boxes are true when command button is clicked it makes only the first box untrue, rather than making all of them untrue. The command buttons work fine on any subsequent occassion when the command button is clicked - it is just when it is the first action on using the userform that the problem occurs! Can anyone explain this or provide a fix for it? Any help much appreciated, its got me baffled. Mike |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
need to minimize userform via command button on itself | Excel Programming | |||
Specifying a Command Button on a worksheet as differentiated from one on a UserForm | Excel Programming | |||
userform checkbox problem with controlsource | Excel Programming | |||
Userform disappears when you try to initialize from a command button | Excel Programming | |||
Excel VBA - Userform Checkbox/Textbox Problem | Excel Programming |