Results 1 to 10 of 10
  1. #1
    SgtSaunders69 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    17

    Enabling and disabling fields

    I want to enable and disable various combinations of text boxes based on what the user selects in a combo pulldown box. The code I have will only make the changes in the first section for the first report listed "All currently open work requests". ... After that nothing runs... no errors.. just doesn't do anything.


    Private Sub Combo21_AfterUpdate()
    If Forms![FRMrpt1]!Combo21! = "All currently open work requests" Then
    Forms![FRMrpt1]!Combo19.Enabled = no
    Forms![FRMrpt1]!Combo26.Enabled = no
    Forms![FRMrpt1]!Combo28.Enabled = no
    Else
    Forms![FRMrpt1]!Combo19.Enabled = yes
    Forms![FRMrpt1]!Combo26.Enabled = yes
    Forms![FRMrpt1]!Combo28.Enabled = yes



    End If
    If Forms![FRMrpt1]!Combo21! = "All Excalated work requests - Closed" Then
    Forms![FRMrpt1]!Combo19.Enabled = yes
    Forms![FRMrpt1]!Combo26.Enabled = yes
    Forms![FRMrpt1]!Combo28.Enabled = no
    Else
    Forms![FRMrpt1]!Combo19.Enabled = no
    Forms![FRMrpt1]!Combo26.Enabled = no
    Forms![FRMrpt1]!Combo28.Enabled = no


    End If

    End Sub

    Any thoughts would be appreciated!

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Does all of this take place on the FRMrpt1 form? How many different values are possible for the Combo21 ComboBox?

  3. #3
    SgtSaunders69 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    17
    Yes.. it does... right now I have 15 reports... so there could be that many different scenarios.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    How about using a Select Case structure?

  5. #5
    SgtSaunders69 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    17
    I'm game.. can you show me some sample code?

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Something like:
    Code:
    Private Sub Combo21_AfterUpdate()
       Select Case Me.Combo21
          Case "All currently open work requests"
             Me.Combo19.Enabled = False
             Me.Combo26.Enabled = False
             Me.Combo28.Enabled = False
          Case "All Excalated work requests - Closed"
             Me.Combo19.Enabled = True
             Me.Combo26.Enabled = True
             Me.Combo28.Enabled = False
          Case Else
             ' Whatever
       End Select
    End Sub

  7. #7
    SgtSaunders69 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    17
    Using this code I'm seeing the same behavior problem with the form. When I select the first report in the combo box the other coded fields enable and disable as desired, but after that the fields will not enable or disable again no matter which other report I select in the combo box.

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Try this and let us know what happens.
    Code:
    Private Sub Combo21_AfterUpdate()
       Select Case Me.Combo21
          Case "All currently open work requests"
             Me.Combo19.Enabled = False
             Me.Combo26.Enabled = False
             Me.Combo28.Enabled = False
          Case "All Excalated work requests - Closed"
             Me.Combo19.Enabled = True
             Me.Combo26.Enabled = True
             Me.Combo28.Enabled = False
          Case Else
             Me.Combo19.Enabled = True
             Me.Combo26.Enabled = True
             Me.Combo28.Enabled = True
       End Select
       MsgBox "The value is: " & Me.Combo21
    End Sub

  9. #9
    SgtSaunders69 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    17
    That worked.... thanks... including the confirmation message...

    Thanks....

  10. #10
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Is this thread ready for you to use the Thread Tools at the top of the thread and mark it Solved?

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

Similar Threads

  1. Command button dis-enabling
    By Reaper in forum Forms
    Replies: 2
    Last Post: 11-23-2011, 10:51 AM
  2. Enabling Option Groups using Macros
    By mnsemple83 in forum Forms
    Replies: 1
    Last Post: 07-15-2011, 06:11 PM
  3. Disabling and Enabling subforms
    By vt800c in forum Programming
    Replies: 3
    Last Post: 05-24-2011, 07:37 AM
  4. Enabling Disabling Combo Boxes from Values
    By vdanelia in forum Forms
    Replies: 3
    Last Post: 02-04-2011, 10:09 AM
  5. Enabling a control and moving to a new tab in vba
    By MuskokaMad in forum Programming
    Replies: 1
    Last Post: 03-14-2010, 05:30 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