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!
  • Students Click Here

*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.

Students Click Here

Microsoft: Access Modules (VBA Coding) FAQ

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.


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

    ' Exit database and quit access

    Exit Sub

    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

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