disable shift key on startup in ms-access

后端 未结 1 1514
野性不改
野性不改 2020-12-15 14:16

Problem: In MS Access you can hold the shift key when opening a database in order to bypass Startup options and the

相关标签:
1条回答
  • 2020-12-15 14:37

    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 讨论(0)
提交回复
热议问题