Skip to content

Latest commit

 

History

History
30 lines (20 loc) · 855 Bytes

hide-a-subform-if-the-main-form-contains-no-records.md

File metadata and controls

30 lines (20 loc) · 855 Bytes
title ms.assetid ms.date ms.localizationpriority
Hide a subform if the main form contains no records
20482340-0c86-71c9-3ba1-b9f515397fbc
09/21/2018
medium

Hide a subform if the main form contains no records

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

[!includeSupport and feedback]