My Assistant
![]() ![]() |
|
|
Feb 23 2012, 01:28 PM
Post
#1
|
|
|
UtterAccess VIP Posts: 6,898 From: Earth... |
Hi My 'Utter Friend's, I am trying to check out the 'Disable MS Access 2007 Close Button In Tis Link: http://www DOT fmsinc DOT com/microsoftaccess/startup/preventclose.asp Anyone know if it works? Cause its not here...: (IMG:style_emoticons/default/iconfused.gif) |
|
|
|
Feb 23 2012, 01:44 PM
Post
#2
|
|
|
UtterAccess VIP Posts: 8,129 From: CT |
do you get an error message? where did you put the "call" on form load ??
|
|
|
|
Feb 23 2012, 01:46 PM
Post
#3
|
|
|
UtterAccess VIP Posts: 6,898 From: Earth... |
Hey Bob, No error, Call is in 'Load' of logOn Form. Thanks, |
|
|
|
Feb 23 2012, 01:54 PM
Post
#4
|
|
|
UtterAccess VIP Posts: 8,129 From: CT |
i gave it a 5 minute trial and it doesnt work for me either.
|
|
|
|
Feb 23 2012, 01:58 PM
Post
#5
|
|
|
UtterAccess VIP Posts: 7,589 From: South coast, England |
Hi Aqua
The method I use is this following code in a CLASS module 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 Private Declare Function GetMenuItemInfo Lib "user32" Alias _ "GetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, ByVal b As _ Long, lpMenuItemInfo As MENUITEMINFO) As Long Private Type MENUITEMINFO cbSize As Long fMask As Long fType As Long fState As Long wID As Long hSubMenu As Long hbmpChecked As Long hbmpUnchecked As Long dwItemData As Long dwTypeData As String cch As Long End Type Const MF_GRAYED = &H1& Const MF_BYCOMMAND = &H0& Const SC_CLOSE = &HF060& Public Property Get Enabled() As Boolean Dim hwnd As Long Dim hMenu As Long Dim Result As Long Dim MI As MENUITEMINFO MI.cbSize = Len(MI) MI.dwTypeData = String(80, 0) MI.cch = Len(MI.dwTypeData) MI.fMask = MF_GRAYED MI.wID = SC_CLOSE hwnd = Application.hWndAccessApp hMenu = GetSystemMenu(hwnd, 0) Result = GetMenuItemInfo(hMenu, MI.wID, 0, MI) Enabled = (MI.fState And MF_GRAYED) = 0 End Property Public Property Let Enabled(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 Property Then this procedure in a normal module: CODE Function InitApplication(intEnab As Boolean) On Error GoTo err_proc 'Enabled or disables the MS application close (X) button - Dependant on state of intEnab 'Uses Class Module 'Close Command' Const C_PROC_NAME = "InitApplication" Dim C As CloseCommand Set C = New CloseCommand C.Enabled = intEnab exit_proc: Exit Function err_proc: MsgBox "Error in Function: '" & C_PROC_NAME & "'" & Chr(13) & err.Description Resume exit_proc End Function Then use InitApplication False ' disables the close button and InitApplication True ' Enables the close button hth |
|
|
|
Feb 23 2012, 01:59 PM
Post
#6
|
|
|
Access Wiki and Forums Moderator Posts: 47,962 From: SoCal, USA |
Hi Aqua,
I've never tried the API approach but there is another way where you don't need to disable the Close button if all you want is prevent accidental exit from Access by the user. Just my 2 cents... (IMG:style_emoticons/default/2cents.gif) |
|
|
|
Feb 23 2012, 02:07 PM
Post
#7
|
|
|
UtterAccess VIP Posts: 6,898 From: Earth... |
Hi Pere, Bob, DB Guy,
I just tried the 'version' in this link and it works. Pere, I'll check out you code also. Thanks guys... (IMG:style_emoticons/default/uarulez2.gif) Forgot the link: http://support DOT microsoft DOT com/kb/300688 |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 22nd May 2013 - 06:55 AM |