Gray out combo box base on value list

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ivonsurf123
    New Member
    • Nov 2017
    • 27

    Gray out combo box base on value list

    Hello,

    I just can't figure out how to grey out the combobox when value chosen is "closed". combobox is set to have a value list in the resource type and the resource is "Open", "Closed"

    Code:
    If Me.[Position_Status] = "Closed" Then
        Me.[Position_Status].Enabled = False
      Else
        Me.[Position_Status].Enabled = True
    End If
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32633

    #2
    I would simplify the code :
    Code:
    With Me
        .Position_Status.Enabled = (.Position_Status.Value <> "Closed")
    End With
    Not forgetting that the code should be in both the form's Current event handler and the control's AfterUpdate event handler. Sensibly, it should be within a procedure that's called from within both event handlers.

    Comment

    • ivonsurf123
      New Member
      • Nov 2017
      • 27

      #3
      Thank you NeoPa, but did not work...The one I submitted does it, but it does not stay gray out(Disabled), it just flash it and go back to showing the field with value enable again when I change to another record. Thank you for helping.

      Comment

      • ivonsurf123
        New Member
        • Nov 2017
        • 27

        #4
        I was able to do it with a conditional formatting instead, it worked perfectly, thank you NeoPa

        In Form Design View:
        • Right-Click on the Combobox
        • Click on Conditional Formatting
        • Under 'Condition1' select Expression Is
        • In the next box, enter [Position Status] = "Closed"
        • Now click on the 'Enabled' icon...the one on the far right (to turn the Enabled property off)
        • Click on OK

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32633

          #5
          Originally posted by IvonSurf
          IvonSurf:
          Thank you NeoPa, but did not work...
          If it didn't work then I don't understand what you want ... or you haven't correctly implemented the suggestion.

          Bear in mind that enabling a Control is only necessary for the current record. If you're using continuous form view (which would be new to this dicussion) then you certainly won't see each record set correctly. However, you will find you can only make the changes at the appropriate points.

          If you are working with continuous forms then Conditional Formatting is probably a better solution.

          Comment

          Working...