次の方法で共有


Visual Basic を使ったフォーム、レポート、およびコントロールのプロパティの設定

FormReportControl オブジェクトは、Microsoft Access オブジェクトです。 これらのオブジェクトのプロパティは、 Sub プロシージャ、 Function プロシージャ、またはイベント プロシージャ内で設定できます。 また、フォーム セクションとレポート セクションのプロパティも設定できます。

フォームまたはレポートのプロパティを設定する

Refer to the individual form or report within the Forms or Reports collection, followed by the name of the property and its value. For example, to set the Visible property of the Customers form to True (-1), use the following line of code:

Forms!Customers.Visible = True

You can also set a property of a form or report from within the object's module by using the object's Me property. Code that uses the Me property executes faster than code that uses a fully qualified object name. For example, to set the RecordSource property of the Customers form to an SQL statement that returns all records with a CompanyName field entry beginning with "A" from within the Customers form module, use the following line of code:

Me.RecordSource = "SELECT * FROM Customers " _ 
    & "WHERE CompanyName Like 'A*'"

コントロールのプロパティを設定する

Refer to the control in the Controls collection of the Form or Report object on which it resides. Controls コレクションを暗黙的または明示的に参照しますが、暗黙的な参照を使用すると、コードの実行速度が速くなります。 The following examples set the Visible property of a text box called CustomerID on the Customers form:

' Faster method. 
Me!CustomerID.Visible = True
' Slower method. 
Forms!Customers.Controls!CustomerID.Visible = True

The fastest way to set a property of a control is from within an object's module by using the object's Me property. たとえば、次のコードを使って、[Customers] フォームの [CustomerID] というテキスト ボックスの "Visible/可視" プロパティを切り替えます。

With Me!CustomerID 
    .Visible = Not .Visible 
End With

フォームまたはレポート セクションのプロパティを設定する

Forms コレクションまたは Reports コレクション内のフォームまたはレポートを参照し、その後に Section プロパティと、個々のセクションを識別する整数または定数を指定します。 次の例では、[Customers] フォームのページ ヘッダー セクションの "Visible/可視" プロパティに False を設定します。

Forms!Customers.Section(3).Visible = False
Me!Section(acPageHeader).Visible = False

関連項目

サポートとフィードバック

Office VBA またはこの説明書に関するご質問やフィードバックがありますか? サポートの受け方およびフィードバックをお寄せいただく方法のガイダンスについては、Office VBA のサポートおよびフィードバックを参照してください。