Quit Access

S

Simon Minder

Hi all

I found a very nice way to hide the access application window on the web.

http://www.tek-tips.com/faqs.cfm?fid=2562

I created on my switchboard a command button, which should close the
application including Access, which is running in the background.
Unfortunately, if I do a "DoCmd.Quit" in VBA or a macro with "Quit", only the
my application closes, but not Access, which remains in the taskbar. In
addition, if I run the VBA code Application.Quit nothing happens at all. It
does not close the window nor does it close Access.

Has anybody an idea how I could close Access as well?

Kind regards,

Simon Minder
 
S

Simon Minder

Hi Alex

Thank you very much for your e-mail.

I found a way to do it.

Instead of adding a button to my Switchboard I created a new form where I
have the question: "Do you want to quit this application?" and a OK and a
Close button. Behind the Close button I have the close from code. Behind the
OK button I run a macro where I run some code (see below) and 'quit' the
application afterwards.

The macro does a RunCode for fAccessWindow ("Show", False, False)

Option Compare Database

Private Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long)
As Long
Dim dwReturn As Long

Const SW_HIDE = 0
Const SW_SHOWNORMAL = 1
Const SW_SHOWMINIMIZED = 2
Const SW_SHOWMAXIMIZED = 3

Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, _
ByVal nCmdShow As Long) As Long

Public Function fAccessWindow(Optional Procedure As String, Optional
SwitchStatus As Boolean, Optional StatusCheck As Boolean) As Boolean
If Procedure = "Hide" Then
dwReturn = ShowWindow(Application.hWndAccessApp, SW_HIDE)
End If
If Procedure = "Show" Then
dwReturn = ShowWindow(Application.hWndAccessApp, SW_SHOWMAXIMIZED)
End If
If Procedure = "Minimize" Then
dwReturn = ShowWindow(Application.hWndAccessApp, SW_SHOWMINIMIZED)
End If
If SwitchStatus = True Then
If IsWindowVisible(hWndAccessApp) = 1 Then
dwReturn = ShowWindow(Application.hWndAccessApp, SW_HIDE)
Else
dwReturn = ShowWindow(Application.hWndAccessApp, SW_SHOWMAXIMIZED)
End If
End If
If StatusCheck = True Then
If IsWindowVisible(hWndAccessApp) = 0 Then
fAccessWindow = False
End If
If IsWindowVisible(hWndAccessApp) = 1 Then
fAccessWindow = True
End If
End If
End Function
 

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