Proper Way to Quit an Application

R

rm

In an application that we have I have created a menu and a macro. The
macro contains 1 command application > quit. The menu item "Exit"
calls the macro. I take it that this isn't the proper way to shutdown
an application because in a large percentage of the time exceptions
are thrown when exiting the application. I have carefully reviewed the
software - none of the recordset, database connections or other
various objects are left "un destroyed" (set x = nothing"). Any advice?
 
R

roger

application.quit


Yes, you should close all open objects, but you should do that at then of
each sub, as soon as you no longer need them not on App quit.

if you have to open obejcts all the time, your exit sub should set them all
to nothing and then application.quit.
 
P

Pete D.

I use this that I threw together wihen having problems with forms closing.

'Created using Terry Kreft Close all open forms and
'For Each" syntax posted on The Access Web

Option Compare Database
Option Explicit
Function ImOutOfHere()
On Error GoTo ImOutOfHere_Err
'Used to close all forms,
'helps prevent errors when quiting access and forms don't close cleanly.
Dim intx As Integer
Dim intCount As Integer
intCount = Forms.Count - 1
For intx = intCount To 0 Step -1
DoCmd.Close acForm, Forms(intx).NAME
Next
DoCmd.Quit acPrompt
ImOutOfHere_Exit:
Exit Function
ImOutOfHere_Err:
MsgBox Error$
Resume ImOutOfHere_Exit
End Function
 
R

rm

Thank you one and all for the answers!!

I use this that I threw together wihen having problems with forms closing..

'Created using Terry Kreft Close all open forms and
'For Each" syntax posted on The Access Web

Option Compare Database
Option Explicit
Function ImOutOfHere()
On Error GoTo ImOutOfHere_Err
    'Used to close all forms,
    'helps prevent errors when quiting access and forms don't close cleanly.
    Dim intx As Integer
    Dim intCount As Integer
    intCount = Forms.Count - 1
    For intx = intCount To 0 Step -1
        DoCmd.Close acForm, Forms(intx).NAME
    Next
    DoCmd.Quit acPrompt
ImOutOfHere_Exit:
    Exit Function
ImOutOfHere_Err:
    MsgBox Error$
    Resume ImOutOfHere_Exit
End Function






- Show quoted text -
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top