Export (0) Print
Expand All

Set Properties by Using Macros [Access 2003 VBA Language Reference]

Office 2003

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:
    • To set a form or report property, use the syntax Forms!formname.propertyname or Reports!reportname.propertyname. For example, the following expression refers to the Visible property of the Customers form:
      Forms!Customers.Visible
      						
    • To set a property of a control on a form or report, use the syntax Forms!formname!controlname.propertyname or Reports!reportname!controlname.propertyname. For example, the following expression refers to the Visible property of the HiddenPageBreak control on the Invoices report:
      Reports!Invoices!HiddenPageBreak.Visible
      						

    propertynameName
  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:

  • Whether you can set the property from a macro.
  • Views in which you can set the property. Not all properties can be set in all views. For example, you can set a form's BorderStyle property only in form Design view.
  • Which values you can use to set the property. Some properties require settings that don't correspond to values in the property sheet but to numeric values. You may need to set the property by using the settings you would use in Visual Basic rather than those you would use in the property sheet. For example, if the property settings are selections from a list, you must use the value or numeric equivalent for each selection.




Show:
© 2014 Microsoft