开发者

disable shift key on startup in ms-access

Problem: In MS Access you can hold the shift key when opening a database in order to bypass Startup options and the AutoExec Script. I want to开发者_高级运维 disable this permanently.

First of all I know this has been answered on numerous other sites, however I could not find a question about it here, but I have a slightly different need.The solutions I found were focused on placing invisible buttons to re-enable the shift-key shortcut with passwords etc.

I want a very simple solution. I want a script I can add to my AutoExec script to disable the shift-key shortcut or something like that.

I DO NOT need a way to re-enable the shift-key shortcut.

The simplest, most secure, and easiest way to do this is preferred.

Thanks!


I have always used this bit of code

Function SetBypass(rbFlag As Boolean, File_name As String) As Integer
    DoCmd.Hourglass True
    On Error GoTo SetBypass_Error
    Dim db As Database
    Set db = DBEngine(0).OpenDatabase(File_name)
    db.Properties!AllowBypassKey = rbFlag
setByPass_Exit:
    MsgBox "Changed the bypass key to " & rbFlag & " for database " & File_name, vbInformation, "Skyline Shared"
    db.Close
    Set db = Nothing
    DoCmd.Hourglass False
    Exit Function


SetBypass_Error:
    DoCmd.Hourglass False
    If Err = 3270 Then
        ' allowbypasskey property does not exist
        db.Properties.Append db.CreateProperty("AllowBypassKey", dbBoolean, rbFlag)

        Resume Next
    Else
        ' some other error message
        MsgBox "Unexpected error: " & Error$ & " (" & Err & ")"
        Resume setByPass_Exit
    End If
End Function

You pass it a filename and then say if you want the bypass key to be enabled or not.

The problem is that anyone else with this code can use it to “Unlock” your database and enable the bypass key.

The only way I can think to get around this would be to only give the users the runtime version of access

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜