Thursday, December 23, 2021

Setproperty macro action

You can use the SetProperty action to set a property for a control on a form or a report in Access desktop databases. You can also use the SetProperty action to set a property for a control on a List or Blank view in an Access web app.

Setting

The SetProperty action has the following arguments.

Action argument

Description

Control Name

Type the name of the field or control for which you want to set the property value. Use only the control name, not the full syntax. Leave this argument blank to set the property for the current form or report.

Property

Select the property that you want to set. See the Remarks section in this article for a list of the properties that can be set by using this action.

Value

Type the value that the property is to be set to. For properties in desktop databases whose values are either Yes or No, use -1 for Yes and 0 for No. For properties in Access web apps whose values are either Yes or No, use Yes and No.

Remarks

  • You can use the SetProperty action in desktop databases to set the following properties of a control: Enabled, Visible, Locked, Left, Top, Width, Height, Fore Color, Back Color, or Caption.

    Note: Not all control types in desktop databases support setting each of the properties listed above.

  • For Access web apps, you can set the following properties of controls: Enabled, Visible, ForeColor, BackColor, Caption, or Value.

    Note: Not all control types in Access web apps support setting each of the properties listed above. You can use the SetProperty macro action only with List and Blank views in Access web apps.

  • If you enter an invalid value for the Value argument, no error occurs, but Access might change the property to a different value, depending on how it interprets the argument.

  • In Access desktop databases, you can use the SetProperty action in a stand-alone macro only if you precede it with an action that selects the form or report containing the control for which you are setting the property. If the form or report is not open, you can use the OpenForm or OpenReport action to open and select it. If the form or report is already open, you can use the SelectObject action to select it. You can then use the SetProperty action to set the property. Selecting the object is not necessary if you use the SetProperty action in a macro which is embedded in a control on the same form or report as the control for which you are setting the property.

  • To run the SetProperty action in a VBA module, use the SetProperty method of the DoCmd object.

Example

The following macro sets the Enabled property of the control named txtDescription to 0 in an Access desktop database. In other words, it disables the control.

Action

Arguments

SetProperty

Control Name: txtDescription

Property: Enabled

Value: 0

No comments:

Post a Comment