Results 1 to 3 of 3
  1. #1
    dolovenature is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2012
    Posts
    14

    Disabling Fields

    Hi,



    I have a FORM based on a Table with some text fields, some combo and three command button.

    What I want is..

    If I select a combo value = "NO" then all the text fields and other combo will be disabled.

    How to achieve that?

    regards
    Saikat

  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
    This type of thing is one way:

    http://www.baldyweb.com/ConditionalVisibility.htm

    If you have a lot of controls, you may want to loop them instead of listing each.
    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
    As Paul said, if you're talking about a fair number of Controls being Enabled/Disabled, you may want to set the Tag Property of those to be handled, then loop through them and Enable or Disable, according to the Value of your Combobox. Code also needs to be in the Form_Current event in order to have the formatting stay appropriate as you move from Record-to-Record.

    In Form Design View

    • Hold down <Shift> and Click on the Controls to be Looped, in order to select them
    • Right-Click then Click on Properties
    • Go to Other Tab
    • In the Tag Property enter Tagged (without Quotation Marks)

    Now use this code, replacing ComboboxName with the actual name of your Combobox.
    Code:
    Private Sub ComboboxName_AfterUpdate()
    
    Dim ctl As Control
    
    If Me.ComboboxName = "No" Then
     
     For Each ctl In Me.Controls
          
      If ctl.Tag = "Tagged" Then
       ctl.Enabled = False
      End If
      
      Next
    
    Else
    
     For Each ctl In Me.Controls
          
      If ctl.Tag = "Tagged" Then
       ctl.Enabled = True
      End If
      
      Next
    
    End If
    
    End Sub


    Code:
    Private Sub Form_Current()
    
    Dim ctl As Control
    
    If Me.ComboboxName = "No" Then
     
     For Each ctl In Me.Controls
          
      If ctl.Tag = "Tagged" Then
       ctl.Enabled = False
      End If
      
      Next
    
    Else
    
     For Each ctl In Me.Controls
          
      If ctl.Tag = "Tagged" Then
       ctl.Enabled = True
      End If
      
      Next
    
    End If
    
    End Sub


    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. Disabling fields
    By bursteffect in forum Access
    Replies: 1
    Last Post: 08-30-2012, 12:54 PM
  2. Disabling fields
    By jle0003 in forum Access
    Replies: 4
    Last Post: 06-06-2012, 09:39 AM
  3. Enabling and disabling fields
    By SgtSaunders69 in forum Programming
    Replies: 9
    Last Post: 12-27-2011, 06:11 PM
  4. Disabling a control
    By NOTLguy in forum Forms
    Replies: 5
    Last Post: 10-31-2010, 11:34 AM
  5. Disabling A Button
    By cksm4 in forum Programming
    Replies: 8
    Last Post: 10-05-2010, 02:07 PM

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