Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
738 views
in Technique[技术] by (71.8m points)

keyboard shortcuts - 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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...