Consulting

Results 1 to 6 of 6

Thread: Solved: Enable command button if in group of option button one option is selected

  1. #1

    Solved: Enable command button if in group of option button one option is selected

    Hi Everyone! I have a problem with my form. The form has two groups of radio buttons or option buttons. Each group has three option buttons in it. Then the form also has a "Next" command button. By default the command button is disabled. I would like the command button to be enabled only if there is one option button selected in each of the groups. So if one option button is selected in group1 and also another option button is selected in group2 then the command button "Next" should be enabled. How can I do this? Thank you very much in advance!

    Edit: the group of option buttons are placed in a frames = frame1 and frame2

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    With Me

    If (.OptionButton1 Or .OptionButton2 Or .OptionButton3) _
    And (.OptionButton4 Or .OptionButton5 Or .OptionButton6) Then

    MsgBox "OK"
    End If
    End With
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Hi Xld! Thank you for your help, I appreciate it! My problem is that I do not understand where to insert the code? To form or frame, or optionbutton or command button??? And instead of messagebox 'OK' I should use commanbutton.enable = true right?
    Thank you!

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    I can't tell you that as it is your design, your code, not mine. Wherever you decide the command button should be enabled is where you put it. It could be on the click of another button, o maybe in the click event of each optionbutton, there are many places.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    I always do things the hard way. Bob has tried but I just can't learn

    Maybe this will give you some ideas.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  6. #6
    Thank you guys for the help! Working fine! Have a nice weekend!

Posting Permissions

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