DoCmd.OpenTable 方法 (Access)DoCmd.OpenTable method (Access)

OpenTable 方法執行 Visual Basic 中的 OpenTable 巨集指令。The OpenTable method carries out the OpenTable action in Visual Basic.

語法Syntax

運算式Opentable 巨集(TableName檢視DataMode)expression.OpenTable (TableName, View, DataMode)

expression 代表 DoCmd 物件的變數。expression A variable that represents a DoCmd object.

參數Parameters

名稱Name 必要/選用Required/Optional 資料類型Data type 描述Description
TableNameTableName 必要Required VariantVariant 字串運算式,代表目前資料庫中資料表的有效名稱。A string expression that's the valid name of a table in the current database. 如果您執行 Visual Basic 程式碼包含程式庫資料庫中的OpenTable方法時,Microsoft Access 會尋找具有此名稱,第一次在程式庫資料庫,然後再到現用資料庫中的資料表。If you execute Visual Basic code containing the OpenTable method in a library database, Microsoft Access looks for the table with this name first in the library database, and then in the current database.
ViewView 選用Optional AcViewAcView 會指定資料表會開啟檢視AcView常數。An AcView constant that specifies the view in which the table will open. 預設值為 acViewNormalThe default value is acViewNormal.
DataModeDataMode OptionalOptional AcOpenDataModeAcOpenDataMode AcOpenDataMode常數,指定表格的資料輸入模式。An AcOpenDataMode constant that specifies the data entry mode for the table. 預設值為 acEditThe default value is acEdit.

註解Remarks

OpenTable 方法可用於資料工作表檢視、 [設計] 檢視或預覽列印] 中開啟資料表。You can use the OpenTable method to open a table in Datasheet view, Design view, or Print Preview. 您也可以選取表格的資料輸入模式。You can also select a data entry mode for the table.

範例Example

下列範例在預覽列印中開啟 [ Employees ] 資料表。The following example opens the Employees table in Print Preview.

DoCmd.OpenTable "Employees", acViewPreview

支援和意見反應Support and feedback

有關於 Office VBA 或這份文件的問題或意見反應嗎?Have questions or feedback about Office VBA or this documentation? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.