+ Reply to Thread
Results 1 to 3 of 3

Check box in user form

  1. #1
    Registered User
    Join Date
    10-24-2005
    Posts
    55

    Check box in user form

    Hi

    I have a user form with 2 check box, but i need help with some code
    I want a error message to appear if box boxes are ticked or both are not

    Also how do unload check boxes and option buttons so after closing the next person using the form has no choice but to select one (this is in case someone select a option but the next person forgets to and leaves the option before which is the wrong one for them!!!!) Hope that makes sense

    here is some of my code already

    If Not (OptionButton6 Or OptionButton7) Then
    MsgBox "No option for job type track only or compelet, please select."
    OptionButton6.SetFocus
    Exit Sub

    Thanks

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Raw,

    You neeed to change the OR to XOR.

    If Not (OptionButton6 Xor OptionButton7) Then

    Sincerely,
    Leith Ross

  3. #3
    Bob Phillips
    Guest

    Re: Check box in user form


    "raw" <[email protected]> wrote in message
    news:[email protected]...
    > I have a user form with 2 check box, but i need help with some code
    > I want a error message to appear if box boxes are ticked or both are
    > not


    Private Sub CheckBox1_Click()
    With Me
    If .CheckBox1.Value = .CheckBox2.Value Then
    MsgBox "Can't both be set/unset"
    .CheckBox1.Value = Not .CheckBox2.Value
    End If
    End With
    End Sub

    Private Sub CheckBox2_Click()
    With Me
    If .CheckBox1.Value = .CheckBox2.Value Then
    MsgBox "Can't both be set/unset"
    .CheckBox2.Value = Not .CheckBox2.Value
    End If
    End With
    End Sub

    Trouble with this is that once you set one or other, you can never change it
    as any other action triggers the error.

    > Also how do unload check boxes and option buttons so after closing the
    > next person using the form has no choice but to select one (this is in
    > case someone select a option but the next person forgets to and leaves
    > the option before which is the wrong one for them!!!!) Hope that makes
    > sense


    Public Sub UserForm_Activate()
    With Me
    .CheckBox1.Value = False
    .CheckBox2.Value = False
    End With
    End Sub




+ 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