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

    Option Group to Enable or Disable a button

    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
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Option Groups don't have Values like "Yes" and "No," their Values are Integers! If the Label on your first Option Button is "Yes" and the Label on the second Option Button is "No," this code should do the job:

    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


    Simply replace YourOptionGroupName and YourCommandButton with the actual names of your Controls.

    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. Enable/Disable Button
    By P.Malius in forum Programming
    Replies: 3
    Last Post: 09-07-2012, 08:36 AM
  2. Replies: 3
    Last Post: 08-02-2012, 10:27 AM
  3. Replies: 5
    Last Post: 03-13-2012, 12:28 PM
  4. Replies: 2
    Last Post: 01-11-2011, 02:00 PM
  5. Replies: 3
    Last Post: 11-02-2010, 10:15 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