Jose Perdigao said:
When I click on the button upper right corner, the access application
close.
I would like create a function to do the follows:
If I click on this button, must show a message to ask the user if do you
really want quit the application, if the response is yes, then close, if
is
no, doesn't close.
is it possible?
anyone can help me?
thanks,
jcp
Better to just disable the button, then you don't have to bother the user
for confirmation. You need to provide them with a means to shut down the
app, of course. All you need is something clickable, like a button, and set
its OnClick to:
Application.Quit
Paste the following code into a standard module:
''' BEGIN CODE '''
Option Compare Database
Option Explicit
'
Private Const MF_BYPOSITION = &H400
Private Const MF_REMOVE = &H1000
'
Private Declare Function DrawMenuBar _
Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function GetMenuItemCount _
Lib "user32" (ByVal hMenu As Long) As Long
Private Declare Function GetSystemMenu _
Lib "user32" (ByVal hWnd As Long, _
ByVal bRevert As Long) As Long
Private Declare Function RemoveMenu _
Lib "user32" (ByVal hMenu As Long, _
ByVal nPosition As Long, _
ByVal wFlags As Long) As Long
Public Sub DisableAccessCloseButton()
Dim appHwnd&, mnuHwnd&, mnuCount&
appHwnd = Application.hWndAccessApp
mnuHwnd = GetSystemMenu(appHwnd, 0)
If mnuHwnd& Then
mnuCount = GetMenuItemCount(mnuHwnd)
'Remove Close
RemoveMenu mnuHwnd, mnuCount - 1, _
MF_REMOVE Or MF_BYPOSITION
'Remove separator line
RemoveMenu mnuHwnd, mnuCount - 2, _
MF_REMOVE Or MF_BYPOSITION
DrawMenuBar appHwnd
End If
End Sub
''' END CODE '''
Then call it when your app starts up.
Note that this will work for all 32 bit versions of Access, except Access
2007 (working on that one).