HI Everyone,
I have an inherited Access database, that my boss converted to Access 2007. I am not a user or developer of Access or VB, but have inherited these nightmares to convert and repair.So can anyone tell me why this code does work (red line):
Thanks!!
Elphaba
I have an inherited Access database, that my boss converted to Access 2007. I am not a user or developer of Access or VB, but have inherited these nightmares to convert and repair.So can anyone tell me why this code does work (red line):
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)
[COLOR=red] Application.CommandBars("File").Controls("Exit").Enabled = blnExitState
[/COLOR]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
Elphaba
Last edited by a moderator: