Access 97 - Application.Quit does not work if msgbox is displayed 
Author Message
 Access 97 - Application.Quit does not work if msgbox is displayed

I am using the form timer event to close an application at a specific time.
This works great if there are no system message boxes displayed.  If a
msgbox is displayed when the Application.quit code executes, the app does
not close.

Is there a method or command to quit the application no matter what,
everytime?

I am trying to force users out at night so I can compact the backend
database.



Fri, 08 Mar 2002 03:00:00 GMT  
 Access 97 - Application.Quit does not work if msgbox is displayed
I use the same method for timed downloads of data and I have to use the
AppActivate statement to cause Access to get the focus and then the
Application.Quit works fine.
I had the same problem when Access did not have the focus (active window)


Quote:
> I am using the form timer event to close an application at a specific
time.
> This works great if there are no system message boxes displayed.  If a
> msgbox is displayed when the Application.quit code executes, the app does
> not close.

> Is there a method or command to quit the application no matter what,
> everytime?

> I am trying to force users out at night so I can compact the backend
> database.



Fri, 08 Mar 2002 03:00:00 GMT  
 Access 97 - Application.Quit does not work if msgbox is displayed
The only way to close a modal dialog would be to run code using a form's
Timer event.  Also be careful  about what type of MsgBox's can be displayed
from your app.  You may not want to close a critical confirmation MsgBox by
force, for example.

Private Sub Command0_Click()
    MsgBox Now
End Sub

Private Sub Form_Timer()
    Debug.Print fCloseMsgBox
End Sub

'******** Code Start *********
Private Declare Function apiFindWindow Lib "user32" _
    Alias "FindWindowA" _
    (ByVal lpClassName As String, _
    ByVal lpWindowName As String) _
    As Long

Private Declare Function apiGetLastActivePopup Lib "user32" _
    Alias "GetLastActivePopup" _
    (ByVal hWndOwnder As Long) _
    As Long

Private Declare Function apiPostMessage Lib "user32" _
    Alias "PostMessageA" _
    (ByVal hWnd As Long, _
    ByVal wMsg As Long, _
    ByVal wParam As Long, _
    ByVal lParam As Long) _
    As Long

Private Const MSGBOX_CLASS = "#32770"
Private Const WM_CLOSE = &H10

Function fCloseMsgBox() As Boolean
Dim hWnd As Long
    hWnd = apiFindWindow(MSGBOX_CLASS, vbNullString)
    If hWnd = apiGetLastActivePopup(hWndAccessApp) Then
        fCloseMsgBox = Not (apiPostMessage(hWnd, WM_CLOSE, 0, 0) = 0)
    End If
End Function
'********* Code End *******

  -- Dev


: I am using the form timer event to close an application at a specific
time.
: This works great if there are no system message boxes displayed.  If a
: msgbox is displayed when the Application.quit code executes, the app does
: not close.
:
: Is there a method or command to quit the application no matter what,
: everytime?
:
: I am trying to force users out at night so I can compact the backend
: database.
:
:
:
:



Fri, 08 Mar 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Getting back the formatted MsgBox in Access 2000 that worked in Access 97

2. DLL usage - works in Access 97 but not in Access 2000

3. Has the Eval function quit working in 97??

4. VB expressions do not work properly in different installations of Access 97

5. Parameterized Update query not working correctly in Access 97

6. Access 97 RecordsetClone not working for Date

7. DeleteObject not working with Access 97

8. Correlated subquery in DELETE stmt not work in Access '97 or 2000

9. ADO OLEDB will not work on Access 97

10. Visdata Grid not working with Access 97

11. LIKE Operator not working as with access 97

12. Microsoft.Jet.OLEDB.4.0 Provider not working with Access 97 MDB

 

 
Powered by phpBB® Forum Software