|
3#
發(fā)表于 2003-3-30 00:16:00
|
只看該作者
AllowBypassKey 屬性
請參閱 示例 特性使用 AllowBypassKey 屬性可以指定是否允許用 Shift 鍵來忽略啟動屬性和 AutoExec 宏。例如,將 AllowBypassKey 屬性設為 False 可避免用戶忽略啟動屬性和 AutoExec 宏。
設置
AllowBypassKey 屬性使用以下設置:
設置 說明
True 允許用戶使用 Shift 忽略啟動屬性和 AutoExec 宏。
False 禁止用戶使用 Shift 忽略啟動屬性和 AutoExec 宏。
可以使用宏或者 Visual Basic 設置該屬性。
若要使用宏或 Visual Basic 設置 AllowBypassKey 屬性,必須使用以下方法創(chuàng)建該屬性:
在 Microsoft Access 數據庫 (.mdb) 中,可以通過使用 CreateProperty 方法添加該屬性,并將其追加到 Database 對象的 Properties 集合中。
注意這里:
在 Microsoft Access 項目 (.adp) 中,可以通過使用 Add 方法將該屬性添加到 CurrentProject 對象的 AccessObjectProperties 集合中。
說明
調試應用程序時,應確保 AllowBypassKey 屬性設為 True。
該屬性的設置僅在下一次打開應用程序數據庫時才會生效。
示例
下面的示例顯示了一個名為 SetBypassProperty 的過程,該過程傳遞要設置的屬性的名稱、數據類型及所需設置。一般用途過程 ChangeProperty 將嘗試設置 AllowBypassKey 屬性,如果找不到該屬性,則用 CreateProperty 方法將其追加到 Properties 集合中。這是必要的步驟,因為只有在添加之后,該屬性才出現(xiàn)在 Properties 集合中。
Sub SetBypassProperty()
Const DB_Boolean As Long = 1
ChangeProperty "AllowBypassKey", DB_Boolean, False
'--------------如果需要解開shift鎖定可以用以下代碼:
'ChangeProperty "AllowBypassKey", DB_Boolean, true
End Sub
Function 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 = True
Change_Bye:
Exit Function
Change_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 If
End Function
|
|