SetProperty Macro Action
You can use the SetProperty action to set a property for a control on a form or a report.
The SetProperty action has the following arguments.
|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 whose values are either Yes or No, use -1 for Yes and 0 for No.|
- You can use the SetProperty action to set the following properties of a control: Enabled, Visible, Locked, Left, Top, Width, Height, Fore Color, Back Color, or Caption.
- 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.
- 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.
The following macro sets the Enabled property of the control named txtDescription to 0. In other words, it disables the control.
Control Name: txtDescription