本文將告訴您,如何停用 SHIFT 鍵,可讓您略過啟動選項的功能。本文也將告訴您,如何強制執行啟動選項,Microsoft Access 資料庫專案中。
針對 Access 檔案所定義的啟動選項決定檔案的看起來和檔案開啟檔案時的行為。 使用啟動使用者介面,或使用
自動執行 巨集,您可以設定啟動選項。
略過啟動所設定的 Access 資料庫專案按住 [SHIFT 鍵時開啟 [存取] 選項的資料庫專案。
或者,來強制執行啟動選項設定的 Access 資料庫專案,停用功能的 SHIFT 鍵,可讓您略過啟動選項]。若要執行此動作請將
AllowBypassKey 屬性設定為 False。
如果要將
AllowBypassKey 屬性設定為 False,請依照下列步驟執行。
Access 專案 (.adp) 的步驟
- 啟動 Access。
- 開啟 Access 資料庫專案。
- 按下 ALT + F11 來開啟 Visual Basic 編輯器。
- 在 Visual Basic] 編輯器中按一下 [檢視] 功能表上的 [即時運算視窗]。
- 輸入下列程式碼或即時運算視窗中貼上下列程式碼,然後按下 ENTER
CurrentProject.Properties.Add "AllowBypassKey", False
- 關閉 [Visual Basic 編輯器] 與 [然後關閉 [Access 資料庫專案。
- 開啟 Access 資料庫專案。請試著略過啟動選項設定為 Access 資料庫專案的開啟 Access 資料庫專案時,按住 SHIFT 鍵。
SHIFT 鍵,可讓您略過啟動選項的功能已停用。 雖然您按住 SHIFT 鍵,以略過啟動選項時,會執行啟動選項。您不能略過啟動選項。
Access 資料庫 (.mdb 或.accdb) 的步驟
- 啟動 Access。
- 新的模組,然後再新增下列兩個功能:
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 - 在 Visual Basic] 編輯器中按一下 [檢視] 功能表上的 [即時運算視窗]。
- 如果想停用 SHIFT 鍵在 即時運算] 視窗中鍵入 ap_DisableShift 並 按下 ENTER。如果想啟用 SHIFT 鍵在 即時運算] 視窗中鍵入 ap_EnableShift 並 按下 ENTER。