Results 1 to 9 of 9
  1. #1
    New Lounger
    Join Date
    Oct 2003
    Location
    Ontario, Canada
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Custom MenuBar (2000 SP-3)

    I am attempting to make a custom menubar. I have managed to add three forms to the menu. How would I close one form when another is selected from the menubar?

  2. #2
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    527
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Custom MenuBar (2000 SP-3)

    docmd.close acform
    or
    docmd.close acform, "Form Name"
    or
    docmd.close acform, "Form Name", option

  3. #3
    New Lounger
    Join Date
    Oct 2003
    Location
    Ontario, Canada
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Custom MenuBar (2000 SP-3)

    Thank you for your prompt response. Where would I put it? I've tried several events. Thank you in advance.

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

    Re: Custom MenuBar (2000 SP-3)

    You probably selected "All Forms" in the list of categories (in the Commands tab of the Customize dialog) and dragged the forms from the commands list to your custom menu bar.

    If you want only one form open at a time, you can follow several strategies:
    <UL><LI>Set the Modal and Popup property of each of the forms to Yes. This means that the user can't select anything outside the form by clicking; the user must close the form before doing anything else in the database.
    <LI>Use the On Open or On Load event of each form to close the others if hey are open. For example in the On Load event of FormA:

    Private Sub Form_Load()
    DoCmd.Close acForm, "FormB", acSaveNo
    DoCmd.Close acForm, "FormC", acSaveNo
    End Sub

    Note: DoCmd.Close doesn't raise an error if you try to close a form that is not open (or doesn't exist, even).
    <LI>Write macros or VBA functions that open one form and close the others. Call these macros or functions in the On Action property of the menu items.[/list]So you have several options to choose from.

  5. #5
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    527
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Custom MenuBar (2000 SP-3)

    So you have a menu where you open one form, then press another menu button and want to open another form thereby closing the first form?

    Thanks,
    Mark

  6. #6
    New Lounger
    Join Date
    Oct 2003
    Location
    Ontario, Canada
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Custom MenuBar (2000 SP-3)

    I have a drop-down menu called Customer, which when dropped, you can select one of three forms (which I had dragged onto the menubar). If I open one form, then go back to the menu to open another, the first one stays open. The thread before this gives me some ideas, but they may be lengthy as I have many forms. Any simpler suggestions? Thank you.

  7. #7
    New Lounger
    Join Date
    Oct 2003
    Location
    Ontario, Canada
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Custom MenuBar (2000 SP-3)

    Thank you for the suggestions. I like the second one best, but am concerned about the lengthy list of forms I have. You have given some things to think about. Thank you.

  8. #8
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    527
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Custom MenuBar (2000 SP-3)

    You could do something like setting a variable when the form in question opens. You would use something like the on open event to set the variable to identify that a specific form is open. Upon opening any of the other two forms you would execute something like this:
    "docmd.close acform strFormname"
    The strFormname is set when you open each form. Keep in mind that if this database file is opened by multiple users at one time, this is probably not the best solution. However, if you are using a front end/back configuration and each user has a copy of the front end running on their own, it should work great.

    Thanks,
    Mark

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

    Re: Custom MenuBar (2000 SP-3)

    If you want only one of the forms open at any time, the Modal/Popup route is by far the easiest. No code at all, no modifications if you decide to add another form, etc.

Posting Permissions

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