MS-ACCESS 如何使用模块修改所有表单的 KeyDown 事件 - 替代禁用 F11 键 hide/unhide 导航窗格

MS-ACCESS How to modify all forms' KeyDown events with a module - alternative disabling F11 key hide/unhide navigation pane

我有一个带有一些表格的数据库。

数据库以登录表单开始,该表单根据登录用户设置 TempVars!CurrentSecurity.Value(如 Admin 或常见的 User)。

所有其他表单都有一个 Form_KeyDown 事件,该事件将调用一个模块,其中有一个 function/sub 必须更改 F11(hide/show 导航窗格)的行为,具体取决于从当前 TempVars!CurrentSecurity.Value (Admin/User).

例如:如果当前登录的帐户是管理员,则启用 F11 键,否则不启用..

所以我这样试过:

在 Form_KeyDown 事件中:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
CheckF11 (KeyCode)
end sub

在模块中:

Public Function CheckF11(KeyCode As Integer)
If TempVars!CurrentSecurity.Value <> "Admin" Then
 If KeyCode = 122 Then KeyCode = 0
End If
End Function

表单的 KeyPreview 属性 已设置为 True,但这无论如何都不起作用。帮助

函数必须将结果发送回调用过程。
Public 函数并没有真正减少代码。

这个有效:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
KeyCode = CheckF11(KeyCode)
End Sub
Public Function CheckF11(intKey As Integer)
If TempVars!CurrentSecurity.Value <> "Admin" Then
 If intKey = 122 Then CheckF11 = 0
End If
End Function