• Close a subform if no data

    • This topic has 3 replies, 2 voices, and was last updated 24 years ago.
    Author
    Topic
    #355769

    I have a form with 2 subforms. How can I not display a subform if there is no data in it base on the data in the main form?

    Viewing 0 reply threads
    Author
    Replies
    • #525417

      If the subforms are properly linked to the parent form with the master and child links, they will automatically show up empty if there are not matching records based on the parent form.

      • #525552

        Thanks for the help. That is working fine, however I would like to make the subform not visible if there is no data for it instead of showing an empty form.

        • #525725

          You need to put a little code into the OnCurrent event procedure of your parent form.

           Private Sub Form_Current()
            If Me!fsubForm.Form.RecordsetClone.RecordCount = 0 Then
              Me!fsubForm.Visible = False
            Else
              Me!fsubForm.Visible = True
            End If
           End Sub

          You’ll have to substitute your subform control name for fsubForm in the code.

    Viewing 0 reply threads
    Reply To: Close a subform if no data

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: