Office 2007 - Access

Lesson 67: Macros (cont 3…)

67/72 Lessons 

AutoExec “Macro”

We had already seen in Lesson 63 how we show the switchboard to open our database.
The same can be achieved with the AutoExec “Macro”.

First open the database, select the “Create” tab and click the “Macro” button.
This opens the “Macro” window.

Select the first field in the “Action” column and select “Open Form” in the drop-down list.
Select “Switchboard” for the “Form Name” in the “Action Arguments”.

Save the “Macro” with the name “AutoExec”.
This name is not case sensitive, but it must be exactly the same name.
But you write it as “Autoexec” or “AutoExec”.
Click the OK button.

Close the database and view the result by re-opening it.

“Macros” group

First let me repeat what an embedded “Macro” is.
An embedded “Macro” is a “Macro” that is assigned to a control, right? Yes.
There is no way we can use this “Macro” with another control, right? No.

“Access” allows us to create a “Macro”-object, which is used as an embedded macro in our database groups and then we can re-use it with other controls.  This is made possible in the “Properties window” by clicking on a button below the “OnClick” event, to see a list of grouped embedded macros, if you click on the downward pointing arrow.

In the example below, I made three buttons (“close”, “phone numbers”, and “open graph”), each with an embedded “Macro”.
Each button has a name in the “Properties window”, under the “Other” tab.
Otherwise, we can not refer to them.
“Closing” is the name of ‘close’.
“Phone” is the name for ‘phone numbers’.
And  ‘graph’ is the name “open graph”.

To group these three macros, click the “Macro” button, under the “Create” tab in the “Ribbon”.

This opens the “Macro” window.
Click the “Macro names” button at the top of the window.
This adds the “Macro Name” column to the window.
In the “Macro name” column, you give the different names, that you just gave to the buttons on the form.
For each name, you give a “Macro” in “Action” and if necessary, a number of arguments.
This must be easy by now.

Click the “Save” button in the “Quick Access” toolbar to save the “Macro”.
Give the “Macro” an appropriate name, eg “my group”, and click the OK button.

Now, when you add a button to your form, you will see that when you click the downward pointing arrow next to the “OnClick” box, these embedded “Macros” are available.

Awesome!
You've completed Lesson 67
START NEXT LESSON