280 likes | 659 Views
Access Tutorial 10 Automating Tasks with Macros. 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.
E N D
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 New Perspectives on Microsoft Office Access 2007
Objectives • 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
Implementing 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
Implementing a Graphical User Interface New Perspectives on Microsoft Office Access 2007
Introduction 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
Directly 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 New Perspectives on Microsoft Office Access 2007
Directly Running an Existing Macro New Perspectives on Microsoft Office Access 2007
Adding Actions to a Macro New Perspectives on Microsoft Office Access 2007
Single 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
Creating 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
Creating 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
Creating an Action by Dragging New Perspectives on Microsoft Office Access 2007
Creating an Action by Dragging New Perspectives on Microsoft Office Access 2007
Macro Groups • A macro group is a macro that contains other macros New Perspectives on Microsoft Office Access 2007
Adding 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
Adding a Macro to a Macro Group New Perspectives on Microsoft Office Access 2007
Adding a Command Button to a Form New Perspectives on Microsoft Office Access 2007
Adding 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
Adding a List Box to a Form New Perspectives on Microsoft Office Access 2007
Using 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
Using SQL New Perspectives on Microsoft Office Access 2007
Adding 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
Adding a Command Button to a Form Using Control Wizards New Perspectives on Microsoft Office Access 2007
Creating 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
Creating a Macro Group New Perspectives on Microsoft Office Access 2007
Creating 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
Creating a Switchboard New Perspectives on Microsoft Office Access 2007