comprehensive access tutorial 10 automating tasks with macros

28
COMPREHENSIVE Access Tutorial 10 Automating Tasks with Macros

Upload: brent-butler

Post on 24-Dec-2015

229 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: COMPREHENSIVE Access Tutorial 10 Automating Tasks with Macros

COMPREHENSIVE

Access Tutorial 10

Automating Tasks with Macros

Page 2: COMPREHENSIVE Access Tutorial 10 Automating Tasks with Macros

XP

New Perspectives on Microsoft Office Access 2007 2

Objectives• 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

Page 3: COMPREHENSIVE Access Tutorial 10 Automating Tasks with Macros

XPObjectives• 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

New Perspectives on Microsoft Office Access 2007 3

Page 4: COMPREHENSIVE Access Tutorial 10 Automating Tasks with Macros

XPImplementing 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 database’s forms, reports, and queries

New Perspectives on Microsoft Office Access 2007 4

Page 5: COMPREHENSIVE Access Tutorial 10 Automating Tasks with Macros

XPImplementing a Graphical User Interface

New Perspectives on Microsoft Office Access 2007 5

Page 6: COMPREHENSIVE Access Tutorial 10 Automating Tasks with Macros

XPIntroduction to Macros• A macro is an action, or a set of actions, that you

want Access to perform automatically for you

New Perspectives on Microsoft Office Access 2007 6

Page 7: COMPREHENSIVE Access Tutorial 10 Automating Tasks with Macros

XPDirectly Running an Existing Macro• In the Macro window, click the Run button in the Tools

group on the Design tab on the RibbonOr• 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

New Perspectives on Microsoft Office Access 2007 7

Page 8: COMPREHENSIVE Access Tutorial 10 Automating Tasks with Macros

XPDirectly Running an Existing Macro

New Perspectives on Microsoft Office Access 2007 8

Page 9: COMPREHENSIVE Access Tutorial 10 Automating Tasks with Macros

XPAdding Actions to a Macro

New Perspectives on Microsoft Office Access 2007 9

Page 10: COMPREHENSIVE Access Tutorial 10 Automating Tasks with Macros

XPSingle 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

New Perspectives on Microsoft Office Access 2007 10

Page 11: COMPREHENSIVE Access Tutorial 10 Automating Tasks with Macros

XPCreating 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

New Perspectives on Microsoft Office Access 2007 11

Page 12: COMPREHENSIVE Access Tutorial 10 Automating Tasks with Macros

XPCreating 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

New Perspectives on Microsoft Office Access 2007 12

Page 13: COMPREHENSIVE Access Tutorial 10 Automating Tasks with Macros

XPCreating an Action by Dragging

New Perspectives on Microsoft Office Access 2007 13

Page 14: COMPREHENSIVE Access Tutorial 10 Automating Tasks with Macros

XPCreating an Action by Dragging

New Perspectives on Microsoft Office Access 2007 14

Page 15: COMPREHENSIVE Access Tutorial 10 Automating Tasks with Macros

XPMacro Groups• A macro group is a macro that contains other

macros

New Perspectives on Microsoft Office Access 2007 15

Page 16: COMPREHENSIVE Access Tutorial 10 Automating Tasks with Macros

XPAdding 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 macro’s 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

New Perspectives on Microsoft Office Access 2007 16

Page 17: COMPREHENSIVE Access Tutorial 10 Automating Tasks with Macros

XPAdding a Macro to a Macro Group

New Perspectives on Microsoft Office Access 2007 17

Page 18: COMPREHENSIVE Access Tutorial 10 Automating Tasks with Macros

XPAdding a Command Button to a Form

New Perspectives on Microsoft Office Access 2007 18

Page 19: COMPREHENSIVE Access Tutorial 10 Automating Tasks with Macros

XPAdding 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 pointer’s 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

New Perspectives on Microsoft Office Access 2007 19

Page 20: COMPREHENSIVE Access Tutorial 10 Automating Tasks with Macros

XPAdding a List Box to a Form

New Perspectives on Microsoft Office Access 2007 20

Page 21: COMPREHENSIVE Access Tutorial 10 Automating Tasks with Macros

XPUsing 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

New Perspectives on Microsoft Office Access 2007 21

Page 22: COMPREHENSIVE Access Tutorial 10 Automating Tasks with Macros

XPUsing SQL

New Perspectives on Microsoft Office Access 2007 22

Page 23: COMPREHENSIVE Access Tutorial 10 Automating Tasks with Macros

XPAdding 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 pointer’s 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

New Perspectives on Microsoft Office Access 2007 23

Page 24: COMPREHENSIVE Access Tutorial 10 Automating Tasks with Macros

XPAdding a Command Button to a Form Using Control Wizards

New Perspectives on Microsoft Office Access 2007 24

Page 25: COMPREHENSIVE Access Tutorial 10 Automating Tasks with Macros

XPCreating 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

New Perspectives on Microsoft Office Access 2007 25

Page 26: COMPREHENSIVE Access Tutorial 10 Automating Tasks with Macros

XPCreating a Macro Group

New Perspectives on Microsoft Office Access 2007 26

Page 27: COMPREHENSIVE Access Tutorial 10 Automating Tasks with Macros

XPCreating a Switchboard• To create the switchboard, you’ll 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

New Perspectives on Microsoft Office Access 2007 27

Page 28: COMPREHENSIVE Access Tutorial 10 Automating Tasks with Macros

XPCreating a Switchboard

New Perspectives on Microsoft Office Access 2007 28