vba 在 ms-access 中启动时禁用 shift 键
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4184455/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
disable shift key on startup in ms-access
提问by kralco626
Problem: In MS Access you can hold the shift keywhen openinga database in order to bypass Startupoptions and the AutoExecScript. I want to disable this permanently.
问题:在 MS Access 中,您可以在打开数据库时按住shift 键以绕过启动选项和AutoExec脚本。我想永久禁用此功能。
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.
我想要一个非常简单的解决方案。我想要一个脚本,我可以添加到我的 AutoExec 脚本中以禁用 shift 键快捷方式或类似的东西。
I DO NOT need a way to re-enablethe shift-key shortcut.
我不需要重新启用shift 键快捷方式的方法。
The simplest, most secure, and easiestway to do this is preferred.
在最简单,最安全和最容易做到这一点的方法是首选。
Thanks!
谢谢!
回答by Kevin Ross
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
我能想到的唯一方法是只为用户提供运行时版本的访问权限