文章編號: 826765 - 上次校閱: 2009年3月4日 - 版次: 4.0

如何強制執行或停用啟動選項,在 Access 資料庫專案

系統提示本文適用於您使用的作業系統之外的作業系統。與您不相關的文章內容已停用。
本文只適用於 Microsoft Access 專案 (.adp)。

中級使用者: 需要基本巨集]、 [程式碼撰寫,] 以及 [交互操作性技巧。

在此頁中

全部展開 | 全部摺疊

結論

本文將告訴您,如何停用 SHIFT 鍵,可讓您略過啟動選項的功能。本文也將告訴您,如何強制執行啟動選項,Microsoft Access 資料庫專案中。

其他相關資訊

針對 Access 檔案所定義的啟動選項決定檔案的看起來和檔案開啟檔案時的行為。 使用啟動使用者介面,或使用 自動執行 巨集,您可以設定啟動選項。

略過啟動所設定的 Access 資料庫專案按住 [SHIFT 鍵時開啟 [存取] 選項的資料庫專案。

或者,來強制執行啟動選項設定的 Access 資料庫專案,停用功能的 SHIFT 鍵,可讓您略過啟動選項]。若要執行此動作請將 AllowBypassKey 屬性設定為 False。

如果要將 AllowBypassKey 屬性設定為 False,請依照下列步驟執行。

Access 專案 (.adp) 的步驟

  1. 啟動 Access。
  2. 開啟 Access 資料庫專案。
  3. 按下 ALT + F11 來開啟 Visual Basic 編輯器。
  4. 在 Visual Basic] 編輯器中按一下 [檢視] 功能表上的 [即時運算視窗]。
  5. 輸入下列程式碼或即時運算視窗中貼上下列程式碼,然後按下 ENTER
    CurrentProject.Properties.Add "AllowBypassKey", False
    
  6. 關閉 [Visual Basic 編輯器] 與 [然後關閉 [Access 資料庫專案。
  7. 開啟 Access 資料庫專案。請試著略過啟動選項設定為 Access 資料庫專案的開啟 Access 資料庫專案時,按住 SHIFT 鍵。

    SHIFT 鍵,可讓您略過啟動選項的功能已停用。 雖然您按住 SHIFT 鍵,以略過啟動選項時,會執行啟動選項。您不能略過啟動選項。

Access 資料庫 (.mdb 或.accdb) 的步驟

  1. 啟動 Access。
  2. 新的模組,然後再新增下列兩個功能:
    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
  3. 在 Visual Basic] 編輯器中按一下 [檢視] 功能表上的 [即時運算視窗]。
  4. 如果想停用 SHIFT 鍵在 即時運算] 視窗中鍵入 ap_DisableShift按下 ENTER。如果想啟用 SHIFT 鍵在 即時運算] 視窗中鍵入 ap_EnableShift按下 ENTER

這篇文章中的資訊適用於:
  • Microsoft Office Access 2007
  • Microsoft Office Access 2003
  • Microsoft Access 2002 Standard Edition
  • Microsoft Access 2000 Standard Edition
關鍵字:?
kbmt kbconfig kbproperties kbadp kbhowto KB826765 KbMtzh
機器翻譯機器翻譯
重要:本文是以 Microsoft 機器翻譯軟體翻譯而成,而非使用人工翻譯而成。Microsoft 同時提供使用者人工翻譯及機器翻譯兩個版本的文章,讓使用者可以依其使用語言使用知識庫中的所有文章。但是,機器翻譯的文章可能不盡完美。這些文章中也可能出現拼字、語意或文法上的錯誤,就像外國人在使用本國語言時可能發生的錯誤。Microsoft 不為內容的翻譯錯誤或客戶對該內容的使用所產生的任何錯誤或損害負責。Microsoft也同時將不斷地就機器翻譯軟體進行更新。
按一下這裡查看此文章的英文版本:826765? (http://support.microsoft.com/kb/826765/en-us/ )
Microsoft及(或)其供應商不就任何在本伺服器上發表的文字資料及其相關圖表資訊的恰當性作任何承諾。所有文字資料及其相關圖表均以「現狀」供應,不負任何擔保責任。Microsoft及(或)其供應商謹此聲明,不負任何對與此資訊有關之擔保責任,包括關於適售性、適用於某一特定用途、權利或不侵權的明示或默示擔保責任。Microsoft及(或)其供應商無論如何不對因或與使用本伺服器上資訊或與資訊的實行有關而引起的契約、過失或其他侵權行為之訴訟中的特別的、間接的、衍生性的損害或任何因使用而喪失所導致的之損害、資料或利潤負任何責任。