应用对象
Microsoft 365 专属 Access Access 2021 Access 2019 Access 2016

可使用 AllowBypassKey 属性指定是否支持使用 SHIFT 键以绕过启动属性和 AutoExec 宏。 例如,可以将 AllowBypassKey 属性设置为“False”以防止用户绕过启动属性和 AutoExec 宏。

设置

AllowBypassKey 属性使用以下设置。

设置

说明

正确

启用 Shift 键以允许用户绕过启动属性和 AutoExec 宏。

错误

禁用 Shift 键以禁止用户绕过启动属性和 AutoExec 宏。

可以使用宏或 Visual Basic for Applications (VBA) 代码设置此属性。

若要使用宏或 Visual Basic for Applications (VBA) 代码设置 AllowBypassKey 属性,则必须通过以下方式创建属性:

  • 在 Microsoft Access 数据库(.mdb 或 .accdb)中,可使用 CreateProperty 方法并将它追加到 Database 对象的 Properties 集合中来添加此属性。

  • 在 Microsoft Access 项目 (.adp) 中,可使用 Add 方法将该属性添加到 CurrentProject 对象的 AccessObjectProperties 集合中。

备注

在调式应用程序时,应确保 AllowBypassKey 属性设置为“True”。

只有在下一次打开应用程序数据库时,AllowBypassKey 属性的设置才会生效。

示例

以下示例演示了传递要设置属性的名称、其数据类型和设置的名为 SetBypassProperty 的过程。 常规用途的过程 ChangeProperty 尝试设置 AllowBypassKey 属性,如果未找到此属性,请使用 CreateProperty 方法将此属性追加到 Properties 集合。 这是必要的,因为在未添加 AllowBypassKey 属性之前,此属性不会出现在 Properties 集合中。

Sub SetBypassProperty()Const DB_Boolean As Long = 1    ChangeProperty "AllowBypassKey", DB_Boolean, FalseEnd SubFunction ChangeProperty(strPropName As String, _    varPropType As Variant, _    varPropValue As Variant) As Integer    Dim dbs As Object, prp As Variant    Const conPropNotFoundError = 3270    Set dbs = CurrentDb    On Error GoTo Change_Err    dbs.Properties(strPropName) = varPropValue    ChangeProperty = TrueChange_Bye:    Exit FunctionChange_Err:    If Err = conPropNotFoundError Then ' Property not found.        Set prp = dbs.CreateProperty(strPropName, _            varPropType, varPropValue)        dbs.Properties.Append prp        Resume Next    Else        ' Unknown error.        ChangeProperty = False        Resume Change_Bye    End IfEnd Function

需要更多帮助?

需要更多选项?

了解订阅权益、浏览培训课程、了解如何保护设备等。