I found a Microsoft article of how to disable the MS Access top close button and the close option in the system menu (when you right click on MS Access entry on the Windows task bar). I modified it to be very simple and it works great when only one form is open. However, when two forms open there is no longer a single MS Access entry on the WIndows task bar, there are individual entries for each form. So of course the close option in the system menu is enabled again as these are not the MS Access entry. So to get around this I figured I could just disable the close option in the new task bar. Easier said than done however.
For the function to disable the MS Access window's top close button and system menu close option I use Application.hWndAccessApp.
When I attempted to disable the individual form window's closing stuff I used Me.hwnd for the argument from within the form. Using Me.Hwnd disabled the forms top close button but not the system menu close option.
What am I doing wrong?
Option Compare Database
Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, _
ByVal bRevert As Long) As Long
Private Declare Function EnableMenuItem Lib "user32" (ByVal hMenu As _
Long, ByVal wIDEnableItem As Long, ByVal wEnable As Long) As Long
Const MF_GRAYED = &H1&
Const MF_BYCOMMAND = &H0&
Const SC_CLOSE = &HF060&
Public Function DisableClose(hWnd As Long)
Dim wFlags As Long
Dim hMenu As Long
hMenu = GetSystemMenu(hWnd, 0)
wFlags = MF_BYCOMMAND Or MF_GRAYED
EnableMenuItem hMenu, SC_CLOSE, wFlags