Using Command Buttons to show/hide subforms on a Form

Posted on 2008-11-04
Last Modified: 2010-04-21
I have a form, called FormA, with subforms: SubFormB1 and SubFormB2.  Here is what I would like to do:

I would like to have two buttons, ButtonB1 and ButtonB2 on the FormA.  When pressed, they would open the respective Subforms.  So, when I push ButtonB1, SubformB1 would open.

The only catch is: these buttons reside on FormA always.  The subforms open on FormA.  So the buttons would open and hide the other subform.  

To possible give a better visual, I imagine this to be (somewhat) like a webpage (FormA) with navigation links along the side (ButtonB1 and ButtonB2) that open contens in a frame (SubFormB1 and SubFormB2) without changing the overall page itself (FormA)

Any help is greatly greatly appreciated.
Question by:mcollins354
    LVL 77

    Accepted Solution

    If you place the subforms one on top of the other then you can make them visible or not.
    You must use the name of subform container control in each case. That might be the same as the name of the subform but it could be different, so you have to check.

    me.containercontrolB.visible = false
    me.containercontrolA.visible = true

    me.containercontrolA.visible = False
    me.containercontrolB.visible = True

    Author Closing Comment

    Excellent!  This is exactly what I needed and it worked great.  Thank you!

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
    Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
    In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
    With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now