Macros are one of the exciting things that make things happen in Access. Conceptually, macros are just a sequence of actions that are grouped together so they can all be executed together as a unit. For example, there may be a set of actions you want to happen when you click on some button (see below) on a form. You might want a button click to result in some form being opened and the contents of the form updated. These two actions (opening the form, setting the value of a control on the form) can be grouped together in a single macro. The button is then set so that the macro executes when the button is clicked. When the macro executes, both activities (in sequence) execute. The types of activities that can be done from within a macro are almost limitless: opening and closing forms, updating controls, executing queries, etc.

There are a number of ways to invoke a macro. Look in the property list of
any control. Under Event Properties you will see things
like: On Enter On Exit On
Click On Dbl Click, etc.

These are all events that the system recognizes. In response to such an event,
you can specify that you want a particular macro to execute.
The setvalue action is used to assign a value to a control on, among other things, a form. The value can take the form of a constant, a computed value, or the value of some other control. In the current example, we would like to create a macro that will open the CD form, and for a new record put an initial value of "Jazz" in the combo box that enables a user to pick the CD category.
To use the setvalue action, begin with the Macro in design view.
You are now prompted for two arguments: Item and Expression. Item refers to the control that is to receive the new value. Expression is the new value or, more precisely, an expression that resolves to some value.
Specifying an Item
The Item must be specified using the full naming syntax which, in general looks something like this: Forms![form name]![control name] While you can type this in, it is in many cases more convenient to use something called the Expression Builder to create it. To use the Expression Builder, click on the Elipsis (looks like three dots: ...) on the right-hand side of the Item argument field. You will see the following:
What you will do is click your way forward until you find the control you want, and the "paste" it into the expression field where you see the cursor in the above window. In the current example,
In the right-hand column, you now see all of the properties of the control you selected in the middle column. For right now, we are, however, only interested in the value of the combo box. We will choose as our "expression" the value of the cmbCategory combo box by now clicking on the Paste button. You will now see the full name of the combo box appear in the expression window.
When you click 'OK', this expression gets placed into the Item argument field in the Macro design view.
For the expression, we wish to enter a constant ("Jazz"). The rule is that we should enclose constants in quotation marks. If we leave out the quotation marks, then Access will interpret our entry as the name of some other control and cause an error.
Now, save the macro.
Previous Section: Buttons and Switchboards