Close Current Database Without Exiting Access

Discussion in 'Microsoft Access Form Coding' started by Clint Marshall, Jul 25, 2005.

  1. I am trying to create a command button on an Access XP form that will close
    the current Access database without exiting the Access Application. This is
    preferred because it will save time the next time we open another database.

    I notice that this functionality isn't available from the file menu. What
    I'm trying to achieve is the equivalent of clicking the "x" on the database
    window.

    I can't figure out the code and it's not available in the command button
    wizard.

    Can anyone guide me or direct me to the code I need?

    Thank you!

    -Clint Marshall
     
    Clint Marshall, Jul 25, 2005
    #1
    1. Advertisements

  2. Clint Marshall

    Rick Brandt Guest

    Clint Marshall wrote:
    > I am trying to create a command button on an Access XP form that will
    > close the current Access database without exiting the Access
    > Application. This is preferred because it will save time the next
    > time we open another database.
    > I notice that this functionality isn't available from the file menu. What I'm
    > trying to achieve is the equivalent of clicking the "x" on
    > the database window.
    >
    > I can't figure out the code and it's not available in the command
    > button wizard.
    >
    > Can anyone guide me or direct me to the code I need?


    Application.CloseCurrentDatabase


    --
    I don't check the Email account attached
    to this message. Send instead to...
    RBrandt at Hunter dot com
     
    Rick Brandt, Jul 25, 2005
    #2
    1. Advertisements

  3. Perfect!
    Thank you!

    -Clint


    "Rick Brandt" <> wrote in message
    news:IdbFe.756$...
    > Clint Marshall wrote:
    >> I am trying to create a command button on an Access XP form that will
    >> close the current Access database without exiting the Access
    >> Application. This is preferred because it will save time the next
    >> time we open another database.
    >> I notice that this functionality isn't available from the file menu. What
    >> I'm trying to achieve is the equivalent of clicking the "x" on
    >> the database window.
    >>
    >> I can't figure out the code and it's not available in the command
    >> button wizard.
    >>
    >> Can anyone guide me or direct me to the code I need?

    >
    > Application.CloseCurrentDatabase
    >
    >
    > --
    > I don't check the Email account attached
    > to this message. Send instead to...
    > RBrandt at Hunter dot com
    >
     
    Clint Marshall, Jul 25, 2005
    #3
  4. Clint Marshall wrote:
    >I am trying to create a command button on an Access XP form that will close
    >the current Access database without exiting the Access Application. This is
    >preferred because it will save time the next time we open another database.
    >
    >I notice that this functionality isn't available from the file menu. What
    >I'm trying to achieve is the equivalent of clicking the "x" on the database
    >window.
    >
    >I can't figure out the code and it's not available in the command button
    >wizard.
    >
    >Can anyone guide me or direct me to the code I need?



    Closing the Database Window is available in the menus by
    first selecting the Database Window and then using the
    File - Close menu item.

    If you want to do this through a form button, then use:
    Application.CloseCurrentDatabase

    If you only want to hide the database window, use:
    DoCmd.SelectObject acTable, , True
    DoCmd.RunCommand acCmdWindowHide

    --
    Marsh
    MVP [MS Access]
     
    Marshall Barton, Jul 25, 2005
    #4
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lisa

    Close a form without saving changes to database

    Lisa, Aug 6, 2003, in forum: Microsoft Access Form Coding
    Replies:
    1
    Views:
    248
    Dirk Goldgar
    Aug 6, 2003
  2. Joy

    Closing objects before exiting in Access 2000

    Joy, Aug 6, 2004, in forum: Microsoft Access Form Coding
    Replies:
    2
    Views:
    235
  3. Guest

    Error exiting database

    Guest, Dec 14, 2004, in forum: Microsoft Access Form Coding
    Replies:
    5
    Views:
    186
    Brendan Reynolds
    Dec 15, 2004
  4. Guest

    VBA Code in an After Update Event Exiting Access - BCP

    Guest, Jan 6, 2005, in forum: Microsoft Access Form Coding
    Replies:
    3
    Views:
    425
    Nick Coe \(UK\)
    Jan 11, 2005
  5. Guest

    Close current and open another database

    Guest, Feb 28, 2007, in forum: Microsoft Access Form Coding
    Replies:
    1
    Views:
    299
    fredg
    Feb 28, 2007
Loading...

Share This Page