Ok I have searched, but haven't found a solution to the minor problem I have, which is just ticking me off at this point.
I use the code below to disable the Acces "X" and Exit in the File menu. It also disables Close (Alt+F4) option when someone right clicks the taskbar of my application. But only at the initial start-up of the program. That is where the problem lies.
When the user starts the app. life is good they can't close it out in any other way than MY WAY. But as soon as they click an option button and a new form opens the one and only close possibility that suddenly becomes available to them is the one where they right click on the task bar and selects CLOSE or ALT+F4.
I got this code from here, so who ever wrote it I'm sorry I didn't save your name on this but great code I am just not using it correctly I'm sure.
I use the code below to disable the Acces "X" and Exit in the File menu. It also disables Close (Alt+F4) option when someone right clicks the taskbar of my application. But only at the initial start-up of the program. That is where the problem lies.
When the user starts the app. life is good they can't close it out in any other way than MY WAY. But as soon as they click an option button and a new form opens the one and only close possibility that suddenly becomes available to them is the one where they right click on the task bar and selects CLOSE or ALT+F4.
I got this code from here, so who ever wrote it I'm sorry I didn't save your name on this but great code I am just not using it correctly I'm sure.
Code:
Option Compare Database
Option Explicit
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 SetEnabledState(blnState As Boolean)
Call CloseButtonState(blnState)
Call ExitMenuState(blnState)
End Function
'Disable the Menu Option
Sub ExitMenuState(blnExitState As Boolean)
Application.CommandBars("File").Controls("Exit").Enabled = blnExitState
End Sub
'Disable the Close Button Option
Sub CloseButtonState(boolClose As Boolean)
Dim hWnd As Long
Dim wFlags As Long
Dim hMenu As Long
Dim result As Long
hWnd = Application.hWndAccessApp
hMenu = GetSystemMenu(hWnd, 0)
If Not boolClose Then
wFlags = MF_BYCOMMAND Or MF_GRAYED
Else
wFlags = MF_BYCOMMAND And Not MF_GRAYED
End If
result = EnableMenuItem(hMenu, SC_CLOSE, wFlags)
End Sub