Microsoft Office Tutorials and References
In Depth Information
Changing the Way Your Form Looks Dynamically
want to display or hide the text box’s label, too, but we’re keeping this
example macro short.
5. Add a SetValue action in the If block.
The SetValue action works for setting properties, too.
6. In the Item argument of the SetValue action, type the name of the
control whose property you want to set, followed by a dot and the
name of the property.
If the control name includes spaces, enclose it in square brackets. (If
the name has no spaces, using square brackets can’t hurt.) Access adds
brackets around the property name for you. In Figure 2-7, the Item
argument is [PO Number].Visible — the Visible property of the PO
Number text box.
Book VI
Chapter 2
7. In the Expression argument box, type the value to which you want to
set the property.
To display the PO Number text box, set its Visible property to Yes or
8. To hide the PO Number text box, add an Else action by clicking the
Add Else link in the If block.
9. Add a SetValue action to the Else action.
10. Set the Item argument to the same property as in Step 6.
You’re still setting the properties of the same control: the PO Number
text box.
11. Set Expression to No or False.
12. Save the macro by pressing Ctrl+S.
13. Open the form in Design view.
14. Set the After Update event property for the Payment Method control
to the name of the submacro you just created.
You may want to set the control’s On Exit event, too, so that the
submacro runs whenever the user’s cursor leaves the control.
When you set the Item argument of the SetValue action to the property
you want to change, you can click the Build button to the right of the Item
box to use Expression Builder.
By default, Access displays only the actions that are allowed in databases
that haven’t been trusted. Click the Show All Actions button in the Show/
Hide group on the Design tab of the Ribbon, below the Macro Tools heading,
to see the complete list of actions in the Action drop-down menu.
Search JabSto ::

Custom Search