Title: Access Tutorial 10 Automating Tasks with Macros
1Access Tutorial 10Automating Tasks with Macros
2Objectives
- Design a switchboard and dialog box for a
graphical user interface - Run and add actions to macros
- Single step a macro
- Create a macro
- Add a macro to a macro group
- Add a command button to a form
- Attach a macro to a command button
3Objectives
- Create a dialog box form
- Add a list box to a form
- Use an SQL statement to fill a list box with
object names - Create a macro group
- Use the Switchboard Manager to create a
switchboard - Modify a switchboard
4Implementing a Graphical User Interface
- A user interface is what you see and use when you
communicate with a computer program - A graphical user interface (GUI) (pronounced
gooey) displays windows, dialog boxes, command
buttons, other controls, and graphical pictures,
called icons, that you use to communicate with a
program - A switchboard is a form that appears when you
open a database and that provides controlled
access to the databases forms, reports, and
queries
5Implementing a Graphical User Interface
6Introduction to Macros
- A macro is an action, or a set of actions, that
you want Access to perform automatically for you
7Directly Running an Existing Macro
- In the Macro window, click the Run button in the
Tools group on the Design tab on the Ribbon - Or
- In the Macro group on the Database Tools tab on
the Ribbon, click the Run Macro button, select
the macro name in the Macro Name list box in the
Run Macro dialog box, and then click the OK
button - Or
- In the Macros group in the Navigation Pane,
right-click the macro name, and then click Run on
the shortcut menu
8Directly Running an Existing Macro
9Adding Actions to a Macro
10Single Stepping a Macro
- Single stepping executes a macro one action at a
time, pausing between actions - In the Macro window, click the Single Step button
in the Tools group on the Design tab on the
Ribbon - Click the Run button in the Tools group on the
Design tab on the Ribbon - In the Macro Single Step dialog box, click the
Step button to execute the next action, click the
Halt button to stop the macro, or click the
Continue button to execute all remaining actions
in the macro and turn off single stepping
11Creating a Macro
- Click the Create tab on the Ribbon
- In the Other group on the Create tab, click the
Macro button - Click the Save button on the Quick Access
Toolbar, type the macro name in the Macro Name
text box, and then press the Enter key
12Creating an Action by Dragging
- Make sure the Macro window and the Navigation
Pane are open - Drag an object from the Navigation Pane to an
Action box in the Macro window. Access adds the
appropriate macro action and sets its arguments
to their default values
13Creating an Action by Dragging
14Creating an Action by Dragging
15Macro Groups
- A macro group is a macro that contains other
macros
16Adding a Macro to a Macro Group
- Open the macro group in the Macro window. (For a
macro group, the Macro Names button is already
selected.) - Type the macro name in the Macro Name column,
select the action in the Action column, type an
optional comment in the Comment column, and then
use the Action Arguments pane to set the macros
arguments - If the macro consists of more than one action,
enter the remaining actions in the rows
immediately following the first macro action.
Leave the Macro Name column blank for each
additional action - Save the macro group
17Adding a Macro to a Macro Group
18Adding a Command Button to a Form
19Adding a List Box to a Form
- Switch to Design view, if necessary
- If necessary, click the Use Control Wizards
button in the Controls group on the Design tab to
deselect it - Click the List Box tool in the Controls group on
the Design tab - Position the pointers plus symbol where you want
to place the upper-left corner of the list box,
and then click the mouse button - If you use the List Box Wizard, complete the
dialog boxes to choose the source of the list,
select the fields to appear in the list box, size
the columns, select the field that will provide
the data for the field in the main form, choose
to remember the value for later use or store it
in a field, and then enter the value to appear in
the list box label - If you do not use the List Box Wizard, set the
Row Source property and size the list box
20Adding a List Box to a Form
21Using SQL
- SQL (Structured Query Language) is a standard
language used in querying, updating, and managing
relational databases - Open the query in Datasheet view or Design view
- Click the SQL View button on the status bar, or
right-click the query tab (or title bar) and
click SQL View on the shortcut menu, or click the
View arrow in the Views group on the Ribbon and
click SQL View
22Using SQL
23Adding a Command Button to a Form Using Control
Wizards
- If necessary, click the Use Control Wizards tool
in the Controls group on the Design tab so that
it is selected - Click the Button tool in the Controls group on
the Design tab - Position the pointers plus symbol where you want
to place the upper-left corner of the command
button, and then click the mouse button - Complete the Command Button Wizard dialog boxes
to select the action category and the action for
the command button, enter the text to display on
the command button, select a picture for the
button, and then enter a name for the button
24Adding a Command Button to a Form Using Control
Wizards
25Creating a Macro Group
- Click the Create tab on the Ribbon
- In the Other group on the Create tab, click the
Macro button - In the Show/Hide group on the Design tab, click
the Macro Names button - Enter the macros in the macro group by entering
each macro name in the Macro Name column and the
corresponding action(s) in the Action column.
Enter comments as needed in the Comment column,
and set arguments as needed in the Action
Arguments pane - Click the Save button on the Quick Access
Toolbar, enter the macro group name in the Macro
Name text box, and then click the OK button
26Creating a Macro Group
27Creating a Switchboard
- To create the switchboard, youll use the Access
Switchboard Manager - The Switchboard Manager also creates a table,
named Switchboard Items, which contains records
describing the command buttons on the switchboard - The Switchboard Manager allows you to create only
one Switchboard form for a database, but the
switchboard can contain many pages
28Creating a Switchboard