ACCESS 禁止用户使用SHIFT启动数据库
这是官方链接,不要去各种百度了: 在数据库中强制实施或禁用启动选项 - Office | Microsoft Learn
'1.启动访问。 '2.创建新模块,然后添加以下两个函数: Function ap_DisableShift() 'This function disable the shift at startup. This action causes 'the Autoexec macro and Startup properties to always be executed. On Error GoTo errDisableShift Dim db As DAO.Database Dim prop as DAO.Property Const conPropNotFound = 3270 Set db = CurrentDb() 'This next line disables the shift key on startup. db.Properties("AllowByPassKey") = False 'The function is successful. Exit Function errDisableShift: 'The first part of this error routine creates the "AllowByPassKey 'property if it does not exist. If Err = conPropNotFound Then Set prop = db.CreateProperty("AllowByPassKey", _ dbBoolean, False) db.Properties.Append prop Resume Next Else MsgBox "Function 'ap_DisableShift' did not complete successfully." Exit Function End If End Function Function ap_EnableShift() 'This function enables the SHIFT key at startup. This action causes 'the Autoexec macro and the Startup properties to be bypassed 'if the user holds down the SHIFT key when the user opens the database. On Error GoTo errEnableShift Dim db as DAO.Database Dim prop as DAO.Property Const conPropNotFound = 3270 Set db = CurrentDb() 'This next line of code disables the SHIFT key on startup. db.Properties("AllowByPassKey") = True 'function successful Exit Function errEnableShift: 'The first part of this error routine creates the "AllowByPassKey 'property if it does not exist. If Err = conPropNotFound Then Set prop = db.CreateProperty("AllowByPassKey", _ dbBoolean, True) db.Properties.Append prop Resume Next Else MsgBox "Function 'ap_DisableShift' did not complete successfully." Exit Function End If End Function '3.在 Visual Basic 编辑器中,单击“视图”菜单上的“即时窗口”。 '4.如果要禁用 SHIFT 密钥,请在“ 即时 ”窗口中键入ap_DisableShift,然后按 Enter。 如果要启用班次键,请在 “即时 ”窗口中键入ap_EnableShift,然后按 ENTER。
这里要提醒一下大家,因为这是官方的资料,也就是说,谁都能看得到,所以最好把 ap_DisableShift 和 ap_EnableShift 这两个函数改成只有自己知道的函数,加强防范