Refer to objects in expressions

Microsoft Office Access 2003

You refer to the value of a control or property in an expression by typing its identifier.

To refer to the value of a control

  • Type the identifier for the form or report that contains the control, followed by the ! operator and the name of the control.

    For example, the following identifier refers to the value of the OrderID control on the Orders form:

    Forms![Orders]![OrderID]

    ShowTip

    If you're referring to a control on a subform or subreport, you don't have to specify the full identifier for the form or report using the Form or Report property. For example, you can use the following identifier to refer to the Quantity control on the Orders Subform subform:

    Forms![Orders]![Orders Subform]![Quantity]

To refer to the value of a property

  • Type the identifier for the form, report, or control to which the property applies, followed by the . (dot) operator, and the name of the property.

    For example, the following identifier refers to the DefaultValue property of the OrderDate control on the Orders form:

    Forms![Orders]![OrderDate].DefaultValue

Notes

ShowA form, report, subform, or subreport

You refer to an open form or report, or the subform or subreport of an open form or report, in an expression by typing its identifier.

To refer to an open form or report

  • Type the name of the Forms or Reports collection, followed by the ! operator and the name of the form or report.

    For example, the following identifier refers to the Orders form:

    Forms![Orders]

To refer to a subform or subreport

Refer to the subform or subreport control on the form or report that contains the subform or subreport, then use the Form or Report property of the control to refer to the actual subform or subreport.

  • Type the identifier for the form or report that contains the subform or subreport, followed by the name of its subform or subreport control, the . (dot) operator, and the Form or Report property.

    For example, the following identifier refers to the Orders Subform subform on the Orders form:

    Forms![Orders]![Orders Subform].Form

Notes

  • You can use the Expression Builder to create an identifier for a form, report, subform, or subreport.
  • When you run a macro or Microsoft Visual Basic for Applications code containing an expression that refers to a form or report, the form or report must be open.

ShowA form or report section or report group level

  • Type the identifier for the form or report, followed by the . (dot) operator and the name of the section or group level.

    For example, the following identifier refers to the detail section on the Orders form:

    [Forms]![Orders].Detail

Notes

  • When you run a macro or Microsoft Visual Basic for Applications code containing an expression that refers to a form or report, the form or report must be open.
  • You can also refer to form or report sections or report group levels by index number using the Section property.

ShowA column in a list

You can refer to a column in a multiple-column list box or combo box by using the Column property of the list box or combo box control.

  • Type the identifier for the Column property, followed by the index number of the column in parentheses. Use 0 (zero) to refer to the first column, 1 to refer to the second column, and so on.

    For example, the following identifier refers to the second column of the Country list box control on the Customers form:

    [Forms]![Customers]![Country].Column(1)

Note  When you run a macro or Microsoft Visual Basic for Applications code containing an expression that refers to a form or report, the form or report must be open.