Results 1 to 4 of 4
  1. #1
    mmg is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2012
    Location
    Fort Hood, TX
    Posts
    3

    Enable/Disable button based on Option Group selection

    I am trying to figure out how to enable or disable a button based on a selection from an option group. I have an option group with "Yes" and "No".


    If the radial button is selected to "Yes" I would like the button enabled to open a form. If the radial button is selected to "No" I would like the button to be disabled. Would anyone know how to fix this and I am trying to also learn VBA, Thanks in advance.

  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Quote Originally Posted by mmg View Post

    ...I have an option group with "Yes" and "No"...
    Option Group Values are Integers, not "Yes" and "No." If the first Radio-Button is labeled 'Yes' and the second one is labeled 'No,' the code would be

    Code:
    Private Sub YourOptionGroupName_AfterUpdate()
     If Me.YourOptionGroupName = 1 Then
      YourCommandButton.Enabled = True
     Else
      YourCommandButton.Enabled = False
     End If
    End Sub
    
    Private Sub Form_Current()
     If Me.YourOptionGroupName = 1 Then
      YourCommandButton.Enabled = True
     Else
      YourCommandButton.Enabled = False
     End If
    End Sub

    You'll need to replace YourOptionGroupName and YourCommandButton with the actual names of your Controls, of course.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    mmg is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2012
    Location
    Fort Hood, TX
    Posts
    3
    Thank You it works, I figured out what I was doing wrong and I really appreciate it.
    Last edited by mmg; 12-01-2012 at 08:34 PM.

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Glad we could help!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 11-30-2012, 08:03 PM
  2. Enable/Disable Button
    By P.Malius in forum Programming
    Replies: 3
    Last Post: 09-07-2012, 08:36 AM
  3. Replies: 5
    Last Post: 03-13-2012, 12:28 PM
  4. Replies: 6
    Last Post: 09-27-2011, 04:39 PM
  5. Replies: 1
    Last Post: 02-25-2011, 10:03 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums