INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Access Environment

Exit Access Application by rohalyla
Posted: 22 Dec 09

Couldn't find code anywhere to close/exit access - so thought I'd post it. I think you can use the button wizard to create a button to do this too, but I usually don't use the wizards and go straight to event code.  This is something I've used many times in my databases - surprised it wasn't a FAQ already.  

This code is behind a button click event.  It closes the form and then exits access.  Note - I use this for an Exit button on the Main Menu or Switchboard screen.  If you use this code somewhere else, I would add code to close any open database objects, before exiting access, to prevent database corruption.  Not that it would, but you never know with Access...

Create form and add button called cmdExitDatabase.  Add this code to the on click event for the button.

CODE

Private Sub cmdExitDatabase_Click()
On Error GoTo Err_cmdExitDatabase_Click
    
    ' First close the form
    DoCmd.Close

    ' Exit database and quit access
    DoCmd.Quit

Exit_cmdExitDatabase_Click:
    Exit Sub

Err_cmdExitDatabase_Click:
    MsgBox Error$
    Resume Exit_cmdExitDatabase_Click
    
End Sub
 

Back to Microsoft: Access Modules (VBA Coding) FAQ Index
Back to Microsoft: Access Modules (VBA Coding) Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close