Results 1 to 4 of 4
  1. #1
    Lounger
    Join Date
    Jan 2001
    Location
    Virginia
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Close a subform if no data

    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?

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Close a subform if no data

    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.
    Charlotte

  3. #3
    Lounger
    Join Date
    Jan 2001
    Location
    Virginia
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Close a subform if no data

    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.

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Close a subform if no data

    You need to put a little code into the OnCurrent event procedure of your parent form.
    <pre> 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</pre>

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •