Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
need to minimize userform via command button on itself Jed[_3_] Excel Programming 1 August 10th 06 09:39 PM
Specifying a Command Button on a worksheet as differentiated from one on a UserForm Amber_D_Laws[_52_] Excel Programming 14 February 7th 06 03:43 PM
userform checkbox problem with controlsource Pierre via OfficeKB.com[_2_] Excel Programming 1 October 30th 05 02:32 PM
Userform disappears when you try to initialize from a command button RPIJG[_60_] Excel Programming 8 July 2nd 04 08:14 PM
Excel VBA - Userform Checkbox/Textbox Problem Thunder5 Excel Programming 1 February 16th 04 02:06 PM


All times are GMT +1. The time now is 07:17 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"