Set Properties by Using Macros

Set Properties by Using Macros

See Also

From a macro, you can set properties for Form, Report, and Control objects, as well as form and report sections. You use the SetValue action from a macro to set the value of a property.

You can't use a macro to set properties of other Microsoft Access objects or ActiveX Data Objects (ADO), or to set the default properties of a control, but you can set them either by using Visual Basic or an object's property sheet in Design view.

To set a form, report, or control property by using a macro

  1. In a macro, add a SetValue action.

  2. Set the Item action argument of the SetValue action to an expression that refers to the property you want to set:

    Tip   If the macro containing the SetValue action runs from the form or report with the property you want to set, you can refer to the property by using just the syntax propertyname. However, it's a good idea to use the full syntax to refer to the property to avoid conflicts with names of controls or Visual Basic keywords. For example, Name is a Microsoft Access property; if you also have a control on your form called Name, you should use the full syntax to refer to both the control and the property.

  3. Set the Expression action argument of the SetValue action to the value you want to set the property to. If the setting is a string, be sure to enclose it in double (") quotation marks. For example, to set the Caption property of a form to Orders, you would enter "Orders" in the Expression argument.

To set a section property by using a macro

  1. In a macro, add a SetValue action.

  2. In the Item action argument, use the syntax Forms!formname.Section(constant).propertyname to refer to the property you want to set. The constant argument refers to a particular section on the form or report, as described in the Section property. For example, the following expression refers to the Visible property of the page header section of the Customers form:
    Forms!Customers.Section(acPageHeader).Visible
  3. Set the Expression action argument as described above.

Note   For each property you want to set, you can look up the property in the Help index to find information about: