• Closing a Form (Access 2000)

    Author
    Topic
    #425581

    I’m creating a form with multiple subforms. The subforms are hidden until a cmd button is clicked and hidden again when they are clicked again. How do I set it up so, the subform closes if they don’t click the cmd button to close it on their own?

    This is what I’ve used to make the subform visible:

    On Click [Event Procedure]

    Private Sub cmdBranded06_Click()
    If sfrm_BrandedFY06.Visible Then
    sfrm_BrandedFY06.Visible = False
    Else
    sfrm_BrandedFY06.Visible = True
    End If
    End Sub

    Viewing 0 reply threads
    Author
    Replies
    • #980872

      When would you like to hide a subform?

      • #980874

        I’m thinking maybe “On Lost Focus” but I honestly don’t know what some of the other options are. They will continue to work on the same form but will probably click one or more of the other buttons to review sales detail and it will get pretty crazy if they’re all open at once. I’m open to suggestions. 🙂

        • #980878

          Why don’t you use a tab control, with a single subform on each tab page. That way, only one subform will be visible at a time, and you don’t need any code.

          • #980887

            The sales reps will want to filter and sort a lot of different ways, depending on what product they want to target. I don’t know how that works with multiple tabs. Will they be able to do that and still have everything stay with the same record when they unfilter?

            I’ll try to attach a sample print screen. There are several categories and I’m giving them a button for each one so they can see the detail that makes up the dollars. There will be 48 detail buttons. I’m certainly open to suggestions. I’ve only put the first three subforms/cmd buttons on so I could go in a different direction but I’m a rookie.

            • #980888

              A subform in a tab page behaves exactly the same way as a subform that is placed directly on the main form. The only difference is that only the subform (and other controls, if any) on the active page of the tab control is visible.
              The tab control would replace the command buttons.

            • #980897

              Hans, you’ve never steared me wrong so I’ll work with it. Would it be possible to get the code to close the subform when it’s lost focus though because there are other times when I’ll need it throughout this project.

              Many thanks,
              Theresa

            • #980903

              A subform as a control on a main form doesn’t have an On Lost Focus event. It has an On Exit event, but you can’t use that to hide the subform. I think it would be very tedious to do. That’s why a tab control is much more convenient, it takes care of hiding/showing the contents of the tab pages without needing code.

            • #980910

              Sounds good. The tab control is a good suggestion for this part of the project anyway.
              Thank you for the support.

    Viewing 0 reply threads
    Reply To: Closing a Form (Access 2000)

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

    Your information: