Results 1 to 9 of 9
  1. #1
    Star Lounger
    Join Date
    Oct 2003
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Closing a Form (Access 2000)

    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

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Closing a Form (Access 2000)

    When would you like to hide a subform?

  3. #3
    Star Lounger
    Join Date
    Oct 2003
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Closing a Form (Access 2000)

    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. :-)

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Closing a Form (Access 2000)

    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.

  5. #5
    Star Lounger
    Join Date
    Oct 2003
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Closing a Form (Access 2000)

    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.

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Closing a Form (Access 2000)

    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.

  7. #7
    Star Lounger
    Join Date
    Oct 2003
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Closing a Form (Access 2000)

    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

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Closing a Form (Access 2000)

    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.

  9. #9
    Star Lounger
    Join Date
    Oct 2003
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Closing a Form (Access 2000)

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

Posting Permissions

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