共用方式為


Application.CreateForm 方法 (Access)

CreateForm 方法會建立表單並傳回 Form 物件。

語法

運算式CreateForm (DatabaseFormTemplate)

expression 代表 Application 物件的變數。

參數

名稱 必要/選用 資料類型 描述
資料庫 選用 Variant 包含您要用來建立表單之表單範本的資料庫名稱。 如果要使用目前資料庫,省略此引數。 如果要使用開啟的程式庫資料庫,利用此引數指定程式庫資料庫。
FormTemplate 選用 Variant 您要用來作為範本來建立新表單的表單名稱。

傳回值

Form

註解

設計建立新表單的精靈時,請使用 CreateForm 方法。

CreateForm 方法會在表單設計檢視中開啟新的、 最小化表單。

如果您用於FormTemplate引數的名稱無效,Visual Basic 會在 [選項] 對話方塊的 [表單/報表] 索引標籤上,使用 [表單模] 設定所指定的表單範本。

範例

本範例會根據 [Customers] 表單 Northwind 範例資料庫中建立新的表單並將其 RecordSource 屬性設定為 [Customers] 資料表。 從 Northwind 範例資料庫中執行這段程式碼。

Sub NewForm() 
 Dim frm As Form 
 
 ' Create form based on Customers form. 
 Set frm = CreateForm("Customers") 
 DoCmd.Restore 
 ' Set RecordSource property to Customers table. 
 frm.RecordSource = "Customers" 
End Sub

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應