[AccessD] Disable F11

Dan Waters dwaters at usinternet.com
Mon May 12 21:31:13 CDT 2008


Hi Arthur - give this a try!  

These three procedures are used to give an Admin person the capability to
switch the database between what I call User Mode and Admin Mode.
  
Part of User Mode is to turn off Special Keys - which turns off F11.  

Note that these properties don't exist until they are created (odd but needs
to be dealt with).  If you run one of the first two procedures and the
property doesn't exist, code in EH will create the property.  The property
is only created once.

Also note that the property changes don't take effect until the database is
shutdown and restarted.  So you MUST create the ability for an admin person
to run StartupPropertiesOn when the system is in User Mode, because they
can't get to the database window.  Also because in my database User Mode has
all the toolbars hidden so no one, including an admin, can get to the
Startup Options.

HTH!
Dan

'---------------------------------------------------------------
Public Sub StartupPropertiesOn()
On Error GoTo EH

    '-- This is Admin mode

    '-- This allows full use of each of these db properties - not secure.

    ChangeProperty "AllowBypassKey", dbBoolean, True
    ChangeProperty "AllowSpecialKeys", dbBoolean, True
    ChangeProperty "AllowBreakIntoCode", dbBoolean, True
    ChangeProperty "AllowBuiltInToolbars", dbBoolean, True
    ChangeProperty "AllowToolbarChanges", dbBoolean, True
    ChangeProperty "AllowFullMenus", dbBoolean, True
    ChangeProperty "StartupShowDBWindow", dbBoolean, True

    Exit Sub

EH:
    Application.Echo True
    Call GlobalErrors("", Err.Number, Err.Description, "Security",
"StartupPropertiesOn", , , "Line " & Erl)

End Sub

'---------------------------------------------------------------
Public Sub StartupPropertiesOff()
On Error GoTo EH

    '-- This is User Mode

    ChangePropertyDemo "AllowBypassKey", dbBoolean, False  '-- No shift key
bypass
    ChangePropertyDemo "AllowSpecialKeys", dbBoolean, False  '-- No F11 key,
can't break into code
    ChangePropertyDemo "AllowBreakIntoCode", dbBoolean, False
    ChangePropertyDemo "AllowBuiltInToolbars", dbBoolean, False
    ChangePropertyDemo "AllowToolbarChanges", dbBoolean, False
    ChangePropertyDemo "AllowFullMenus", dbBoolean, False
    ChangePropertyDemo "StartupShowDBWindow", dbBoolean, False

    Exit Sub

EH:
    Application.Echo True
    Call GlobalErrors("", Err.Number, Err.Description, "Security",
"StartupPropertiesOff", , , "Line " & Erl)

End Sub

'---------------------------------------------------------------
Public Function ChangeProperty(stgPropName As String, varPropType As
Variant, varPropValue As Variant) As Boolean
On Error GoTo EH

    Dim prp As DAO.Property
    Const conPropNotFoundError As Integer = 3270

    CurrentDb.Properties(stgPropName) = varPropValue
    ChangeProperty = True

    Exit Function

EH:
    Application.Echo True
    GlngErrNumber = Err.Number
    GstgErrDescription = Err.Description
    Select Case GlngErrNumber
        Case 3265
            FormattedMsgBox GstgNotReady, "You are not an Administrator for
this database.@ @", vbExclamation + vbOKOnly, "Not Authorized"
        Case 3270
            '-- Add property if not already created
            Set prp = CurrentDb.CreateProperty(stgPropName, varPropType,
varPropValue)
            CurrentDb.Properties.Append prp
            Resume Next
        Case Else
            ' Unknown error.
            ChangeProperty = False
            Call GlobalErrors("", GlngErrNumber, GstgErrDescription,
"Security", "ChangeProperty", , , "Line " & Erl)
    End Select

End Function

'---------------------------------------------------------------

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Arthur Fuller
Sent: Monday, May 12, 2008 6:44 PM
To: Access Developers discussion and problem solving
Subject: [AccessD] Disable F11

While my current app is in testing, F11 (open the database window) is
enabled, but when we get to lock-down I want to disable this. I'm not sure
how I do this. To further complicate things, I have four user levels, the
topmost of which is Admin, and these people should be able to do this.

Advice and guidance is invited.

TIA,
Arthur
-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list