Results 1 to 7 of 7

Thread: Disable Command Button when Radio Button Enabled

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2012
    Posts
    18

    Cool Disable Command Button when Radio Button Enabled

    I was looking for a code to have multiple actions with a radio button
    When the radio button pressed, need the CB2 (command button) disabled and contents from Text-1 copied to Text-2
    Can some please help me to make a code to make this happen?
    See the picture

    Name:  userform1-buttons.jpg
Views: 1114
Size:  13.2 KB

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Disable Command Button when Radio Button Enabled

    First thing. Once the radio button is clicked, it cannot be unclicked by the user. Wouldn't that be an issue? Maybe a checkbox would be better?

    In either case. Within that control's click event
    Code:
    If Option1.Value = True Then ' or if a checkbox: If Check1.Value = vbChecked Then
         CB2.Enabled = False
         Text2.Text = Text1.Text
    End If
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,622

    Re: Disable Command Button when Radio Button Enabled

    Quote Originally Posted by LaVolpe View Post
    Wouldn't that be an issue? Maybe a checkbox would be better?
    OR, as an alternative, place TWO option buttons on the form, then you COULD uncheck one or the other.

  4. #4
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Disable Command Button when Radio Button Enabled

    Quote Originally Posted by SamOscarBrown View Post
    OR, as an alternative, place TWO option buttons on the form, then you COULD uncheck one or the other.
    Or, simply toggle the option button back to False just before the click event exits. But in either case, disabling the 2nd command button doesn't make sense unless the action is meant to be 1-time only
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jun 2012
    Posts
    18

    Re: Disable Command Button when Radio Button Enabled

    LaVolpe,
    I am not a VB expert. I am trying to add this to an existing macro.
    It's running on VBA 7 environment.
    I tried the above code and it doesn't work
    Can I move this to VB.net?

  6. #6
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Disable Command Button when Radio Button Enabled

    Quote Originally Posted by wire-brush View Post
    LaVolpe,
    I am not a VB expert. I am trying to add this to an existing macro.
    It's running on VBA 7 environment.
    I tried the above code and it doesn't work
    Can I move this to VB.net?
    If you would've mentioned VBA, we could've advise you to post it in the Office portion of the forum. I'll inform a moderator so they can move this for you.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  7. #7
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Disable Command Button when Radio Button Enabled

    Thread moved from the 'VB6' forum to the 'Office Development/VBA' forum (while VBA and VB6 have some similarities, they are not the same thing)

    (thanks for letting us know LaVolpe )

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width