+ Reply to Thread
Results 1 to 5 of 5

is there not a simpler way

  1. #1
    Registered User
    Join Date
    06-29-2006
    Posts
    60

    is there not a simpler way

    I have 3 Checkboxes each with its own procedures, that is linked to a command button, like below, but when you select any combination of the boxes a Msgbox: must pop up saying please select only 1 checkboxs at a time.
    How do i do that?

    Private Sub CommandButton6_Click()
    If CheckBox1 = True And CheckBox2 = False And CheckBox4 = False Then
    Sheet14.Activate
    Unload UserForm1
    Else
    End If

    If CheckBox2 = True And CheckBox1 = False And CheckBox4 = False Then
    Sheet6.Activate
    Unload UserForm1
    Else
    End If

    If CheckBox4 = True And CheckBox1 = False And CheckBox2 = False Then
    Sheet1.Activate
    Call RunProgramSequence1
    Else
    End If

    End Sub

    'MsgBox "Please make only one 'Planning' selection" & Err.Description, vbExclamation, "AI-Program: Power Utility Pack 2006"

  2. #2
    NickHK
    Guest

    Re: is there not a simpler way

    Don't use check boxes, use Option button instead.
    They are designed to mutually exclusive.

    NickHK

    "T.c.Goosen1977"
    <[email protected]> wrote in
    message news:[email protected]...
    >
    > I have 3 Checkboxes each with its own procedures, that is linked to a
    > command button, like below, but when you select any combination of the
    > boxes a Msgbox: must pop up saying please select only 1 checkboxs at a
    > time.
    > How do i do that?
    >
    > Private Sub CommandButton6_Click()
    > If CheckBox1 = True And CheckBox2 = False And CheckBox4 = False Then
    > Sheet14.Activate
    > Unload UserForm1
    > Else
    > End If
    >
    > If CheckBox2 = True And CheckBox1 = False And CheckBox4 = False Then
    > Sheet6.Activate
    > Unload UserForm1
    > Else
    > End If
    >
    > If CheckBox4 = True And CheckBox1 = False And CheckBox2 = False Then
    > Sheet1.Activate
    > Call RunProgramSequence1
    > Else
    > End If
    >
    > End Sub
    >
    > 'MsgBox "Please make only one 'Planning' selection" & Err.Description,
    > vbExclamation, "AI-Program: Power Utility Pack 2006"
    >
    >
    > --
    > T.c.Goosen1977
    > ------------------------------------------------------------------------
    > T.c.Goosen1977's Profile:

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




  3. #3
    Registered User
    Join Date
    06-29-2006
    Posts
    60

    Yes, simpler there is!

    Thanks Nick

  4. #4
    Brill2
    Guest

    Re: is there not a simpler way

    But if you must use Radio Buttons then you can check to see if the
    value of the other radio buttons has been checked. I don't know the
    code off the top of my head (I'll check for you if you need it), but
    you can say something to the extent

    'Inside verification code check the other 2 boxes to see if they are
    checked
    if(checkbox1 = checked) or (checkbox2 = checked) Then
    msgbox "Please only select one checkbox."
    'uncheck all boxes
    checkbox1.checked = false
    checkbox2.checked = false
    checkbox3.checked = false
    end if

    HTH,
    Brill2


    T.c.Goosen1977 wrote:
    > I have 3 Checkboxes each with its own procedures, that is linked to a
    > command button, like below, but when you select any combination of the
    > boxes a Msgbox: must pop up saying please select only 1 checkboxs at a
    > time.
    > How do i do that?
    >
    > Private Sub CommandButton6_Click()
    > If CheckBox1 = True And CheckBox2 = False And CheckBox4 = False Then
    > Sheet14.Activate
    > Unload UserForm1
    > Else
    > End If
    >
    > If CheckBox2 = True And CheckBox1 = False And CheckBox4 = False Then
    > Sheet6.Activate
    > Unload UserForm1
    > Else
    > End If
    >
    > If CheckBox4 = True And CheckBox1 = False And CheckBox2 = False Then
    > Sheet1.Activate
    > Call RunProgramSequence1
    > Else
    > End If
    >
    > End Sub
    >
    > 'MsgBox "Please make only one 'Planning' selection" & Err.Description,
    > vbExclamation, "AI-Program: Power Utility Pack 2006"
    >
    >
    > --
    > T.c.Goosen1977
    > ------------------------------------------------------------------------
    > T.c.Goosen1977's Profile: http://www.excelforum.com/member.php...o&userid=35895
    > View this thread: http://www.excelforum.com/showthread...hreadid=558313



  5. #5
    NickHK
    Guest

    Re: is there not a simpler way

    I would hate such a UI, because checkboxes visually indicate that these
    choices are not exclusive, whilst option buttons visually indicate the
    opposite.
    However, if your aim is to confuse the user, then that would do it.
    NickHK

    "Brill2" <[email protected]> wrote in message
    news:[email protected]...
    > But if you must use Radio Buttons then you can check to see if the
    > value of the other radio buttons has been checked. I don't know the
    > code off the top of my head (I'll check for you if you need it), but
    > you can say something to the extent
    >
    > 'Inside verification code check the other 2 boxes to see if they are
    > checked
    > if(checkbox1 = checked) or (checkbox2 = checked) Then
    > msgbox "Please only select one checkbox."
    > 'uncheck all boxes
    > checkbox1.checked = false
    > checkbox2.checked = false
    > checkbox3.checked = false
    > end if
    >
    > HTH,
    > Brill2
    >
    >
    > T.c.Goosen1977 wrote:
    > > I have 3 Checkboxes each with its own procedures, that is linked to a
    > > command button, like below, but when you select any combination of the
    > > boxes a Msgbox: must pop up saying please select only 1 checkboxs at a
    > > time.
    > > How do i do that?
    > >
    > > Private Sub CommandButton6_Click()
    > > If CheckBox1 = True And CheckBox2 = False And CheckBox4 = False Then
    > > Sheet14.Activate
    > > Unload UserForm1
    > > Else
    > > End If
    > >
    > > If CheckBox2 = True And CheckBox1 = False And CheckBox4 = False Then
    > > Sheet6.Activate
    > > Unload UserForm1
    > > Else
    > > End If
    > >
    > > If CheckBox4 = True And CheckBox1 = False And CheckBox2 = False Then
    > > Sheet1.Activate
    > > Call RunProgramSequence1
    > > Else
    > > End If
    > >
    > > End Sub
    > >
    > > 'MsgBox "Please make only one 'Planning' selection" & Err.Description,
    > > vbExclamation, "AI-Program: Power Utility Pack 2006"
    > >
    > >
    > > --
    > > T.c.Goosen1977
    > > ------------------------------------------------------------------------
    > > T.c.Goosen1977's Profile:

    http://www.excelforum.com/member.php...o&userid=35895
    > > View this thread:

    http://www.excelforum.com/showthread...hreadid=558313
    >




+ 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