How do I turn off the Control Box for the MS Access Application

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

My Access Databases employ database stamping including user-level session
tracking. But it is not foolproof. Users can still bypass the session close
out by simply clicking on the close icon in the Access control box ( you
know, min, resize and close in the upper right corner). How do I turn that
thing off so that users are forced to use the right exit feature?
 
You can get around this by using setting the startup option (Tools -- Startup)
..

I can remeber which options do what exactly, but I think that by unchecking
the "Display Database WIndow" would hide the buttons from the users. You
should also uncheck the "Use Access Special Keys" as an Access savy use would
likely know how to get around the hidden database window...

HTH,

Corey
 
Ensure that you have a form that's always open (it doesn't have to be
visible).

In that form's Unload event, put logic to set Cancel = True unless you
actually want to close the form. (A common approach is to have a global
variable that you'd set to True if they've used the appropriate exit
feature, and then check the value of that variable)
 
Hi,
I copied this code from where I forgot. You can disable Close button on Ms
Access windows.

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 Sub CloseButtonState(ByVal blnClose As Boolean)
Dim hwnd As Long
Dim wFlags As Long
Dim hMenu As Long
Dim result As Long

On Error GoTo CloseButtonState_ErrHandler
hwnd = Application.hWndAccessApp
hMenu = GetSystemMenu(hwnd, 0)

If Not blnClose Then
wFlags = MF_BYCOMMAND Or MF_GRAYED

Else
wFlags = MF_BYCOMMAND And Not MF_GRAYED

End If

result = EnableMenuItem(hMenu, SC_CLOSE, wFlags)

CloseButtonState_NormalExit:
Exit Sub

CloseButtonState_ErrHandler:
MsgBox Err.Description & ". Error number = " & Err.Number
Resume CloseButtonState_NormalExit
End Sub
 
Back
Top