Show / Hide Fields

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Prometheus73
    New Member
    • May 2021
    • 1

    Show / Hide Fields

    Is it at all possible to show or hide fields based on a selection from a drop down box. I am new to access but have built a database, I have around 7 different options to choose from. But only one should trigger the other fields to appear.

    Thanks 🙏 again for your help...
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32661

    #2
    Not only possible, but a common requirement :-) Welcome to Bytes.com.

    In the _AfterUpdate() event procedure you would have code that sets the visibility of other Controls (Not Fields exactly - Fields do little more than hold data whereas Controls are a little more complicated.) based on the value found in your other Control.

    At a very basic level, if you have a Form (frmX), a ComboBox Control (cboY) and just one TextBox Control (txtZ) to be shown (if cboY = "A") or hidden (if cboY = {anything else}) then you would want code based on this simple template :
    Code:
    Private Sub cboY_AfterUpdate()
        Dim blnVisible As Boolean
    
        With Me
            blnVisible = .cboY = "A"
            .txtZ.Visible = blnVisible
        End With
    End Sub

    Comment

    • isladogs
      Recognized Expert Moderator Contributor
      • Jul 2007
      • 483

      #3
      For info, if this is being done in a table, query or datasheet form, you can just right click and Select Hide Fields

      Comment

      Working...