Form.Form Property

Access Developer Reference

You can use the Form property to refer to a form or to refer to the form associated with a subformcontrol. Read-only Form.

Syntax

expression.Form

expression   A variable that represents a Form object.

Remarks

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

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.

Visual Basic for Applications
  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.

Visual Basic for Applications
  =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.

Visual Basic for Applications
  X = MyFunction(Forms!Customers!CustomerID)
Bb240730.vs_note(en-us,office.12).gif  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.

Visual Basic for Applications
  Dim curTotalAmount As Currency

curTotalAmount = Forms!Orders!OrderDetails.Form!TotalAmount

See Also