Unanswered: Hide Application Close Button Access 2013
I am new to this forum so please be patient. I am also new to developing Access and would like to hide the application close/min/max so the user is forced to select the button for Quit Application on my main form. I have tried numerous ways but none have seemed to work with Access 2013 or I am not programming correctly. I had the following procedure working at one time but now it isn't.
I appreciate any help you can offer,
I tried this procedure is to disable the Min/Max/Close on application.
Copy the following into a new module:
Option Compare Database
Private Const GWL_EXSTYLE = (-20)
Private Const GWL_STYLE = (-16)
Private Const WS_MAXIMIZEBOX = &H10000
Private Const WS_MINIMIZEBOX = &H20000
Private Const WS_SYSMENU = &H80000
Private Const HWND_TOP = 0
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_FRAMECHANGED = &H20
Private Const SWP_DRAWFRAME = SWP_FRAMECHANGED
Private Declare Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" (ByVal hWnd As Long, _
ByVal nIndex As Long, ByVal dwNewLong As Long) _
Private Declare Function GetWindowLong Lib "user32" _
Alias "GetWindowLongA" (ByVal hWnd As Long, _
ByVal nIndex As Long) As Long
Private Declare Function SetWindowPos Lib "user32" _
(ByVal hWnd As Long, ByVal hWndInsertAfter As Long, _
ByVal X As Long, ByVal Y As Long, ByVal cx As Long, _
ByVal cy As Long, ByVal wFlags As Long) As Long
Dim lngStyle As Long
lngStyle = GetWindowLong(hWndAccessApp, GWL_STYLE)
lngStyle = lngStyle And Not WS_SYSMENU
Call SetWindowLong(hWndAccessApp, GWL_STYLE, lngStyle)
Call SetWindowPos(hWndAccessApp, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_DRAWFRAME)
Then from my main forms on load event call it with:
'Call module to hide access application close button
Last edited by billgyrotech; 07-19-13 at 13:44.
Reason: Adding the code
If you have some VBA code you would like to run that is behind your button, put a reference to the procedure in your forms On Close event and it will still fire regardless of how Access is closed, the only problem is you can't stop Access from closing.
With regards to your function, if your running a new version of windows (7 or 8) it may no longer like your code, check this out.