disable shift key on startup in ms-access

只愿长相守 提交于 2019-11-29 00:29:04

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!