+ Reply to Thread
Results 1 to 7 of 7

enable/disable start button on basis of chkbox conditions

  1. #1
    Forum Contributor
    Join Date
    06-02-2005
    Location
    India
    MS-Off Ver
    2007
    Posts
    138

    Question enable/disable start button on basis of chkbox conditions

    I hv various chkboxes on my userform.

    If any of this chkbox value is true then enable the "START" button else disable.

    Plz note: One chkbox is to select and deselect all other chkboxes. Also if any other chkbox value

    is set to false, then the chkbox(select-deselect all) becomes false.

    Example file is attached with codes of selecting/deselecting all. I required now this to reflect

    accordingly to "Start" button to enable/disable.
    Attached Files Attached Files

  2. #2
    Bob Phillips
    Guest

    Re: enable/disable start button on basis of chkbox conditions

    Assuming that the button is called cmdStart

    Option Explicit

    Private mEnableEvents As Boolean

    Private Sub CheckBox1_Click()
    With Me
    If mEnableEvents Then
    mEnableEvents = False
    mEnableEvents = False
    .CheckBox2.Value = .CheckBox1.Value
    .CheckBox3.Value = .CheckBox1.Value
    .CheckBox4.Value = .CheckBox1.Value
    .CheckBox5.Value = .CheckBox1.Value
    .cmdStart.Enabled = True
    mEnableEvents = True
    End If
    End With
    End Sub

    Private Sub CheckBox2_Click()
    With Me
    If mEnableEvents Then
    SetCheckboxes .CheckBox2
    End If
    End With
    End Sub

    Private Sub CheckBox3_Click()
    With Me
    If mEnableEvents Then
    SetCheckboxes .CheckBox3
    End If
    End With
    End Sub

    Private Sub CheckBox4_Click()
    With Me
    If mEnableEvents Then
    SetCheckboxes .CheckBox4
    End If
    End With
    End Sub

    Private Sub CheckBox5_Click()
    With Me
    If mEnableEvents Then
    SetCheckboxes .CheckBox5
    End If
    End With
    End Sub

    Private Sub UserForm_Activate()
    mEnableEvents = True
    Me.cmdStart.Enabled = False
    End Sub

    Private Sub SetCheckboxes(thisCb As MSForms.CheckBox)
    With Me
    mEnableEvents = False
    If Not thisCb.Value Then
    .CheckBox1.Value = False
    .cmdStart.Enabled = False
    ElseIf .CheckBox2.Value And .CheckBox3.Value And _
    .CheckBox4.Value And .CheckBox5.Value Then
    .CheckBox1.Value = True
    .cmdStart.Enabled = True
    End If
    mEnableEvents = True
    End With
    End Sub





    --
    HTH

    Bob Phillips

    "ilyaskazi" <[email protected]> wrote
    in message news:[email protected]...
    >
    > I hv various chkboxes on my userform.
    >
    > If any of this chkbox value is true then enable the "START" button else
    > disable.
    >
    > Plz note: One chkbox is to select and deselect all other chkboxes. Also
    > if any other chkbox value
    >
    > is set to false, then the chkbox(select-deselect all) becomes false.
    >
    > Example file is attached with codes of selecting/deselecting all. I
    > required now this to reflect
    >
    > accordingly to "Start" button to enable/disable.
    >
    >
    > +-------------------------------------------------------------------+
    > |Filename: Book3.zip |
    > |Download: http://www.excelforum.com/attachment.php?postid=3451 |
    > +-------------------------------------------------------------------+
    >
    > --
    > ilyaskazi
    > ------------------------------------------------------------------------
    > ilyaskazi's Profile:

    http://www.excelforum.com/member.php...o&userid=23969
    > View this thread: http://www.excelforum.com/showthread...hreadid=376218
    >




  3. #3
    Forum Contributor
    Join Date
    06-02-2005
    Location
    India
    MS-Off Ver
    2007
    Posts
    138

    Question

    Oops, I forget to say that if other all chkboxes value is false then dont set the cmdStart button as true.

    ALL CHKBOX is FALSE then cmdStart.enabled=false

    upon clicking any chkbox if other chkboxes value is true, then keep button enable.

  4. #4
    Bob Phillips
    Guest

    Re: enable/disable start button on basis of chkbox conditions

    Option Explicit

    Private mEnableEvents As Boolean

    Private Sub CheckBox1_Click()
    With Me
    If mEnableEvents Then
    mEnableEvents = False
    mEnableEvents = False
    .CheckBox2.Value = .CheckBox1.Value
    .CheckBox3.Value = .CheckBox1.Value
    .CheckBox4.Value = .CheckBox1.Value
    .CheckBox5.Value = .CheckBox1.Value
    If .CheckBox1.Value Then
    .cmdStart.Enabled = True
    End If
    mEnableEvents = True
    End If
    End With
    End Sub

    Private Sub CheckBox2_Click()
    With Me
    If mEnableEvents Then
    SetCheckboxes .CheckBox2
    End If
    End With
    End Sub

    Private Sub CheckBox3_Click()
    With Me
    If mEnableEvents Then
    SetCheckboxes .CheckBox3
    End If
    End With
    End Sub

    Private Sub CheckBox4_Click()
    With Me
    If mEnableEvents Then
    SetCheckboxes .CheckBox4
    End If
    End With
    End Sub

    Private Sub CheckBox5_Click()
    With Me
    If mEnableEvents Then
    SetCheckboxes .CheckBox5
    End If
    End With
    End Sub

    Private Sub UserForm_Activate()
    mEnableEvents = True
    Me.cmdStart.Enabled = False
    End Sub

    Private Sub SetCheckboxes(thisCb As MSForms.CheckBox)
    With Me
    mEnableEvents = False
    If Not thisCb.Value Then
    .CheckBox1.Value = False
    ElseIf .CheckBox2.Value And .CheckBox3.Value And _
    .CheckBox4.Value And .CheckBox5.Value Then
    .CheckBox1.Value = True
    .cmdStart.Enabled = True
    End If
    If Not .CheckBox2.Value And Not .CheckBox3.Value And _
    Not .CheckBox4.Value And Not .CheckBox5.Value Then
    .cmdStart.Enabled = False
    End If
    mEnableEvents = True
    End With
    End Sub





    --
    HTH

    Bob Phillips

    "ilyaskazi" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Oops, I forget to say that if other all chkboxes value is false then
    > dont set the cmdStart button as true.
    >
    > ALL CHKBOX is FALSE then cmdStart.enabled=false
    >
    > upon clicking any chkbox if other chkboxes value is true, then keep
    > button enable.
    >
    >
    > --
    > ilyaskazi
    > ------------------------------------------------------------------------
    > ilyaskazi's Profile:

    http://www.excelforum.com/member.php...o&userid=23969
    > View this thread: http://www.excelforum.com/showthread...hreadid=376218
    >




  5. #5
    Forum Contributor
    Join Date
    06-02-2005
    Location
    India
    MS-Off Ver
    2007
    Posts
    138

    Question

    no no no.... output is not what i wanted.

    Let me clear you again...

    If i set value of chkbox1 = true then
    chkbox2=true
    chkbox3=true
    chkbox4=true
    chkbox5=true
    (set all other chkboxes=true) and
    cmdStart.enabled=true

    elseif i set value of chkbox1= false then
    chkbox2=false
    chkbox3=false
    chkbox4=false
    chkbox5=false
    (set all other chkboxes=false) and
    cmdStart.enabled=false

    Also....
    if i set value of chkbox2=false then check value of other chkboxes(3,4,5)
    and if value of all chkboxes(3,4,5)=false then
    cmdStart.enabled=false
    elseif any of the chkboxes(3,4,5)=true then
    cmdStart.enabled=true

    same for other chkboxes(3,4,5) check and apply.

    example is attached. plz see for reference.
    Attached Files Attached Files

  6. #6
    Bob Phillips
    Guest

    Re: enable/disable start button on basis of chkbox conditions

    Sorry I couldn't help you.

    Bob

    "ilyaskazi" <[email protected]> wrote
    in message news:[email protected]...
    >
    > no no no.... output is not what i wanted.
    >
    > Let me clear you again...
    >
    > If i set value of chkbox1 = true then
    > chkbox2=true
    > chkbox3=true
    > chkbox4=true
    > chkbox5=true
    > (set all other chkboxes=true) and
    > cmdStart.enabled=true
    >
    > elseif i set value of chkbox1= false then
    > chkbox2=false
    > chkbox3=false
    > chkbox4=false
    > chkbox5=false
    > (set all other chkboxes=false) and
    > cmdStart.enabled=false
    >
    > Also....
    > if i set value of chkbox2=false then check value of other
    > chkboxes(3,4,5)
    > and if value of all chkboxes(3,4,5)=false then
    > cmdStart.enabled=false
    > elseif any of the chkboxes(3,4,5)=true then
    > cmdStart.enabled=true
    >
    > same for other chkboxes(3,4,5) check and apply.
    >
    > example is attached. plz see for reference.
    >
    >
    > +-------------------------------------------------------------------+
    > |Filename: Book6.zip |
    > |Download: http://www.excelforum.com/attachment.php?postid=3453 |
    > +-------------------------------------------------------------------+
    >
    > --
    > ilyaskazi
    > ------------------------------------------------------------------------
    > ilyaskazi's Profile:

    http://www.excelforum.com/member.php...o&userid=23969
    > View this thread: http://www.excelforum.com/showthread...hreadid=376218
    >




  7. #7
    Forum Contributor
    Join Date
    06-02-2005
    Location
    India
    MS-Off Ver
    2007
    Posts
    138

    Thumbs up

    Its ok. But your code has helped me solving it like this...

    Please Login or Register  to view this content.
    and it is working fine according to my requirement. Plz check.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1