Hide a Text Box based on Combo Box selection

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • djchaney3
    New Member
    • Jan 2014
    • 7

    Hide a Text Box based on Combo Box selection

    Hello, I am working on an Access 2007 database and I am having issues on a multiple record form, getting a text box control (titled: IOPCount) to be hidden unless a combo box control (titled: Request_Type) indicates the value "OBS/SUP".

    I located a rather fantastic post on this site (here) but when I use this code and I change the Request_Type control of 1 record it hides or unhides the IOPCount control of ALL records. here is the code I used from the above link:

    Code:
    Private Sub Request_Type_AfterUpdate()
    
    If Request_Type = "OBS/SUP" Then
    
              IOPCount.Visible = True     'Set text box to visible
              
         Else
              IOPCount.Visible = False     'Hide the text box
              
         End If
    
    End Sub
    My question is: "How do I get this code to only hide the IOPCount control of the record it is associated with?"
  • TheSmileyCoder
    Recognized Expert Moderator Top Contributor
    • Dec 2009
    • 2322

    #2
    Hi and welcome to Bytes
    You can't do that sadly, in that way. The controls in a continuous form are "repeated" so to say between records, and as such they share certain properties, such as the .Visible property.

    The best you can do in a continuous form is to use conditional formatting.

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32636

      #3
      DJChaney3
      "... but when I use this code and I change the Request_Type control of 1 record ..."
      Therein lies the rub. Form controls are not related to any record. They are related to the form. Different instances may show different data, but the control itself is the same whichever record is currently being shown. Any change to the properties of that control will affect any and all records that are shown using that control.

      Why Values in Unbound Form Controls do not Persist may be helpful to read for a fuller understanding.

      Comment

      • djchaney3
        New Member
        • Jan 2014
        • 7

        #4
        Thank you very much. I have switched over to use Conditional formatting. However I ran into the issue with this were I can not conditionally format the label... why I am not sure but it will not allow it :(

        Any idea on that one?

        Comment

        • TheSmileyCoder
          Recognized Expert Moderator Top Contributor
          • Dec 2009
          • 2322

          #5
          I don't really know, as I haven't used it much myself. For me to give any troubleshooting tips however, you need to provide more details on
          * What have you tried
          * Explain what Access is doing, and what you expected it to do

          Comment

          • zmbd
            Recognized Expert Moderator Expert
            • Mar 2012
            • 5501

            #6
            djchaney3: New Question New Thread (^_^)

            Comment

            • djchaney3
              New Member
              • Jan 2014
              • 7

              #7
              Sorry for a second question under same post, but I did figure it out. Thank you all for assisting me
              Last edited by zmbd; Jan 8 '14, 02:40 AM. Reason: [Z{No Edit{You're Always Welcome... BOL! (^_^)}]

              Comment

              Working...