Table of contents
XML
TOC
Collapse the table of content
Expand the table of content

Hide a Subform if the Main Form Contains No Records

office 365 dev account|Last Updated: 6/12/2017
|
1 Contributor

The following example illustrates how to hide a subform named Orders_Subform if its main form does not contain any records. The code resides in the main form's Current event procedure.

Private Sub Form_Current() 

    With Me![Orders_Subform].Form 

        ' Check the RecordCount of the Subform. 
        If .RecordsetClone.RecordCount = 0 Then 

            ' Hide the subform. 
            .Visible = False 

        End If 
    End With 
End Sub
© 2018 Microsoft