How to open a sub form with command button

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • adbjlb1
    New Member
    • Aug 2019
    • 1

    How to open a sub form with command button

    I have a Search form "SearchF" with 2 fields Equipment # and Location.

    I build the query "SearchQ" with criteria
    Code:
    (Like "*" & [Forms]![SearchF]![Equipment #] & "*")
    and
    Code:
    (Like "*" & [Forms]![SearchF]![Location] & "*")
    Then I built the form "SearchQF"

    The search button is in the main form. I have the sub form "results". The command works great using vba
    Code:
    Private Sub Searchbar_Click()
    Me!Results.Form.RecordSource = "SearchQ"
    End Sub
    The only thing is I do not want to see the sub form when I open the search form (datasheet view). I want the sub form hidden until I hit the search button in the main form.

    Can anyone help?
    Last edited by NeoPa; Aug 23 '19, 03:50 AM. Reason: Tidied up messy text and formatted as required using the [CODE] tags.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32664

    #2
    You have two main options :
    1. Make the SubForm Control (That is a Control and not the form itself.) invisible.
    2. Set which Form is used in the SubForm Control only when you want it to be viewed.

    Comment

    Working...