Form Property

Microsoft Access Visual Basic

Show All Show All

Form Property

You can use the Form property to refer to a form or to refer to the form associated with a subform control.

Remarks

This property refers to a form object. It is read-only in all views.

You can use this property by using a macro or Visual Basic.

This property is typically used to refer to the form or report contained in a subform control. For example, the following code uses the Form property to access the OrderID control on a subform contained in the OrderDetails subform control.

Dim intOrderID As Integer
intOrderID = Forms!Orders!OrderDetails.Form!OrderID
		

The next example calls a function from a property sheet by using the Form property to refer to the active form that contains the control named CustomerID.

=MyFunction(Form!CustomerID)
		

When you use the Form property in this manner, you are referring to the active form, and the name of the form isn't necessary.

The next example is the Visual Basic equivalent of the preceding example.

X = MyFunction(Forms!Customers!CustomerID)
		

Note   When you use the Forms collection, you must specify the name of the form.

Example

The following example uses the Form property to refer to a control on a subform.

Dim curTotalAmount As Currency

curTotalAmount = Forms!Orders!OrderDetails.Form!TotalAmount