Hiding Subforms in Access

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PotatoChip
    New Member
    • Jan 2008
    • 26

    Hiding Subforms in Access

    I have a form which tracks Change Requests. Sometimes documentation needs to be updated as a result of the change. So, instead of bogging down the form with mulitple comment fields, I have created a subform to input any affected documents. Is there a way to hide the subform (as the form is already quite messy and large) if no documents are affected? I was thinking if the user ticks a checkbox indicating documents are affected, the subform would show. Any help would be awesome.

    Thanks!

    PotatoChip
    (no dip)
  • Megalog
    Recognized Expert Contributor
    • Sep 2007
    • 378

    #2
    Sure can! I do this all the time.. this is exactly how:

    Put in that checkbox, we'll call it chkChange here.
    Bind it to a new Yes/No field in the parent form's table.
    Set the subform visible property to 'False' when your parent form Loads, or in Design view.
    Then, in the Click event for the checkbox, AND the OnCurrent event for the parent form, you would do the following:

    Code:
    Call ChangeDocSubformToggle
    which will call upon the following code:

    Code:
    Private Sub ChangeDocSubformToggle
    
    If Me.chkChange.Value = True Then
        Me.ChangeDocument_Subform.Visible = True
        Me.ChangeDocument_Subform.Requery 'This line might not be needed, I use it because Access 2007 gets buggy without it on my forms.
    
    Else
        Me.ChangeDocument_Subform.Visible = False
        Me.Refresh  'This line might not be needed, I use it because Access 2007 gets buggy without it on my forms.
    End If
    
    End Sub

    Comment

    • PotatoChip
      New Member
      • Jan 2008
      • 26

      #3
      Thanks! At first it didn't work but then I played with it and taking out the Toggle bits seemed to do the trick! Lol...people at work think I'm some computer genius...little do they know...muhahaha !

      Comment

      • Megalog
        Recognized Expert Contributor
        • Sep 2007
        • 378

        #4
        Your secret is safe with us!
        Glad you got it to work, btw.

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32634

          #5
          How about :
          Code:
          Me.ChangeDocument_Subform.Visible = Me.chkChange

          Comment

          Working...