Working with Macros. Creating a Macro

Similar documents
Navigating a Database Efficiently

Switchboard. Creating and Running a Navigation Form

To complete this database, you will need the following file:

To complete this database, you will need the following file:

Access Review. 4. Save the table by clicking the Save icon in the Quick Access Toolbar or by pulling

Excel 2007 New Features Table of Contents

Creating a Custom Report

Creating Automated Dashboard Excel 2013 Contents

Chapter11 practice file folder. For more information, see Download the practice files in this book s Introduction.

PRODUCTIVITY TIPS USING OUTLOOK Washtenaw Community College

Getting Started with Access

What s New in Access 2007

Microsoft Access 2013 Lab #01 Part #01

USING MICROSOFT ACCESS 2013 Guided Project 7-1

Microsoft Access 2013

Inserting or deleting a worksheet

Access Intermediate

INSERT SUBTOTALS Database Exercise Sort the Data Department Department Data Tab Sort and Filter Group

Access Intermediate

Objective 1: Familiarize yourself with basic database terms and definitions. Objective 2: Familiarize yourself with the Access environment.

Microsoft How to Series

Skills Exam Objective Objective Number

Key Terms. Differentiation Extended Time Four square

Access. Basics PRESENTED BY THE TECHNOLOGY TRAINERS OF THE MONROE COUNTY LIBRARY SYSTEM

MS Access Let s begin by looking at the toolbar and menu of Access.

Microsoft Access II 1.) Opening a Saved Database Music Click the Options Enable this Content Click OK. *

Section 1 Getting Started

Table of Contents COURSE OVERVIEW... 5

Excel 1. Module 6 Data Lists

To complete this database, you will need the following file:

Department of Instructional Technology & Media Services Blackboard Grade Book

CUSTOMIZING CHECKPOINT TO WORK FOR YOU

Introduction to macros

INSIGHT SITE ADMINISTRATOR MANUAL

Lesson 1: Getting Started with

Procurement Contract Overview

COPYRIGHTED MATERIAL. Making Excel More Efficient

Microsoft Office 2010: Introductory Q&As Access Chapter 2

ERC: Portal Favorites Advanced Options Quick Reference Guide

SITE DESIGN & ADVANCED WEB PART FEATURES...

Creating Accessible PDFs

Open Book Format.docx. Headers and Footers. Microsoft Word Part 3 Office 2016

Astra Scheduling Grids

Working with Data in Microsoft Excel 2010

Create a Customised Tab on the Office 2013 Ribbon

Microsoft Powerpoint 2013

How to Upgrade Your Site to the New User Interface

Microsoft Power Tools for Data Analysis #04: Power Query: Import Multiple Excel Files & Combine (Append) into Proper Data Set.

Database Design Lab: MS Access Queries

Using Excel to Troubleshoot EMIS Data

Status Bar: Right click on the Status Bar to add or remove features.

More Skills 11 Format and Position Report Controls

Colleague UI4.3 Documentation

Excel The primary replacement for menus and toolbars in Office Excel 2007 is the Ribbon. Designed for easy browsing, the

4. In the Address Book drop-down list, click the address book that contains the addresses you want in your distribution list.

Tips & Tricks: MS Excel

Microsoft Access 2010

Adding Content. 4. The following page will display (see image to the right): 5. Enter the title of the text page in the Name* field (required).

Office 2010: Transition from Office Contents. Moving to Microsoft Office Microsoft Office 2010 Project Transition from Office 2003

Introduction. Table Basics. Access 2010 Working with Tables. Video: Working with Tables in Access To Open an Existing Table: Page 1

4 Timesaving Tips for Word 2010

AutoCAD 2009 User InterfaceChapter1:

2. create the workbook file

Create an Accessible PDF (Adobe Acrobat Pro)

Printing spreadsheets is easy. Microsoft Excel has lots of options available so you can print exactly what you want.

Microsoft Word 2016 Advanced

Microsoft Access 2010

DbSchema Forms and Reports Tutorial

AHC SharePoint 2010 Intro to Content Administration

PowerPoint Essentials 1

When you pass Exam : Access 2010, you complete the requirements for the Microsoft Office Specialist (MOS) - Access 2010 certification.

Microsoft Outlook Basics

Microsoft Access 2013

Using Microsoft Word. Text Editing

Microsoft Access 2013

Microsoft Excel 2007

Filter and PivotTables in Excel

New Perspectives on PowerPoint Module 2: Adding Media and Special Effects

To complete this database, you will need the following file:

ORGANISING MESSAGES. In this session you will: FOCUS

Using Modules in Canvas

Using Microsoft Word. Paragraph Formatting. Displaying Hidden Characters

Intermediate Microsoft Access 2010

Lesson 1: Exploring Excel Return to the FastCourse Excel 2007 Level 1 book page

Table of Contents. 1. Creating a Microsoft Excel Workbook...1 EVALUATION COPY

Lab - Task Scheduler in Windows 8

Word Long Docs Quick Reference (Windows PC)

More Skills 14 Write Macros to Create Custom Menus

Enforce Referential. dialog box, click to mark the. Enforce Referential. Integrity, Cascade Update Related Fields, and. Cascade Delete Related

DOING MORE WITH EXCEL: MICROSOFT OFFICE 2010

Microsoft Power BI Tutorial: Importing and analyzing data from a Web Page using Power BI Desktop

Getting Started in the Online Lab

Outlook Create a Contact Group

DOING MORE WITH EXCEL: MICROSOFT OFFICE 2013

Lesson 5 Styles, Tables, and Frames

MSOffice WORD Microsoft Office 20 13

Lab - Monitor and Manage System Resources in Windows 7 and Vista

Microsoft Office Access Learn how to use the Query window in Design view. Tutorial 3b Querying a Database

Saving a Workbook That Contains Macros

Module Five: Lists in Excel

Transcription:

Working with Macros 1 Working with Macros THE BOTTOM LINE A macro is a set of actions saved together that can be performed by issuing a single command. Macros are commonly used in Microsoft Office applications, including Microsoft Office Access, to simplify a complicated task that you must perform frequently or to add functionality such as buttons to Microsoft Access forms, reports, and controls. For example, you can use a macro to enter your name and contact information, format a list of items, resize an image in your document, or call a report from a data entry form. Creating a Macro Before you can use a macro, you must create the macro. To create a macro, you build the list of actions to be performed, provide information to perform the action, and specify any criteria that must be met before the action is performed. Create a Macro GET READY. Before you begin these steps, be sure to launch Access and OPEN the Students_Fourth_Coffee database from the data files provided. (See your instructor for the location of the data files.) 1. If a security warning is displayed below the Ribbon, click the Options button following the warning. The Microsoft Office Security Options dialog box is displayed, as shown in Figure 1. Figure 1 Microsoft Office Security Options dialog box Enable content

Working with Macros 2 2. Click the Enable this content radio button and click OK. Macros are enabled so they will function in this document. If you close and reopen the file, you will need to repeat steps 1 and 2. 3. Click the Create tab on the Ribbon, as shown in Figure 2. Create tab Macro button Figure 2 Create tab on the Ribbon Collapsed Navigation Pane TROUBLESHOOTING Note that your window may differ if the Navigation Pane is expanded.

Working with Macros 3 4. In the Other group on the Ribbon, click the Macro button. The Macro Builder is displayed, as shown in Figure 3. Figure 3 Macro Builder Macro tools Action dropdown list Arguments 5. Select OpenReport from the Action dropdown list. Based on the action you selected, arguments are displayed in the Arguments column next to the Action field and in the Action Arguments area in the lower part of the window, as shown in Figure 4. Figure 4 Action selected Expand Navigation Pane Action selected Arguments column Arguments displayed 6. Click the arrows on the Navigation Pane to expand it. Additional items in the Students_Fourth_Coffee database are displayed.

Working with Macros 4 7. In the expanded Navigation Pane, click All Students and then drag it to the Report Name argument. The All Students report is added as an argument, as shown in Figure 5. Figure 5 All Students report added as an argument All Students report in Navigation Pane Drag the report to the Report Name argument 8. Click the Run button in the Tools group on the Ribbon. A warning message is displayed stating that you must save the macro before you can run it. Click Yes. A small Save As dialog box is displayed, as shown in Figure 6. Figure 6 Naming a new macro

Working with Macros 5 9. Select the Macro1 suggested name, if necessary, and key View Students. Click OK. The All Students report is displayed and the View Students macro appears in the Unassigned Objects section of the Navigation Pane, as shown in Figure 7. Figure 7 View Students macro created View Students macro created All Students report displayed 10. Close all objects and SAVE your database as Students_Fourth_Coffee2. PAUSE. LEAVE the database open to use in the next exercise. In the preceding exercise, you created a very simple macro that performs a single action. It displays a report. In Access, however, a macro can perform many complicated actions or a series of complicated actions. In fact, Access macros are very similar to a simplified programming language. An Access macro consists of actions, arguments, and conditions. An action tells the macro what it will do, such as display a report or display a message box. Every macro has at least one action. An argument provides information to the action. For example, an argument tells the action which report or message to display. Based on the action, some arguments are required, while others are optional. For example, if you want the macro to display a report, you must specify the report. Finally, the macro might have conditions that specify when an action is performed. The macro you created in the preceding exercise did not have conditions. The action will occur every time the macro runs. In the preceding exercise, you created a stand-alone macro. A stand-alone macro is a separate Access object that is displayed in the Navigation Pane. Beginning with Microsoft Access 2007, you can also create an embedded macro. An embedded macro is not displayed in the Navigation Pane. Instead, an embedded macro is part of the object running the macro, such as a form, a report, or a button. Use a stand-alone macro if you want to use

Working with Macros 6 the macro in several locations. Use an embedded macro if you don t want to track where individual stand-alone macros are used. Using a Macro A macro can save you a lot of time and effort while ensuring consistency when repeating the same functionality in another location. Of course, to gain these benefits you must use the macro. In the following exercise, you will add the macro you created to an existing form. Use a Macro USE the database from the preceding exercise. If you closed and reopened the database, remember to enable the database content. 1. In the expanded Navigation Pane, right-click Student Details and click Design View. The Student Details form is displayed in Design View, as shown in Figure 8. In Design View, you can add, modify, or remove items on the form. Figure 8 Display Student Details in Design View Right-click Student Details form Student Details form in Design View 2. Use the scroll bars in the Design View pane to center the view on the Notes button on the form.

Working with Macros 7 3. In the Navigation Pane, click View Students. Drag the macro and drop it to the right of the Notes button in the Design View pane. The macro is displayed as a button on the form, as shown in Figure 9. Figure 9 Drag and drop the macro on the form Adjust the scroll bars to center the location Drag macro from the Navigation Pane Drop the macro on the form 4. In the Navigation Pane, double-click Student Details. The Student Details form is displayed, as shown in Figure 10. The View Students button is displayed in the form. Figure 10 View Students button added to the Student Details form View Students button

Working with Macros 8 5. On the Student Details form, click View Students. Minimize the Student Details form if necessary to view the All Students report, as shown in Figure 11. Figure 11 All Students report displayed All Students report 6. Close the Student Details form. A warning message will be displayed asking if you want to save changes to the Student Details form design. Click Yes. 7. SAVE your database. PAUSE. LEAVE the database open to use in the next exercise. In the preceding exercise, you added the View Students macro to the existing Student Details form. Use the same process to add the macro to any form or report. You can add the macro to an existing report to run the report specified in the macro. Editing a Macro A macro is not always perfect when it is created. Changes in the use of your database might require changes to your macro. For these and many other possible reasons, you might need to edit a macro. Edit a Macro USE the database from the preceding exercise. If you closed and reopened the database, remember to enable the database content.

Working with Macros 9 1. In the expanded Navigation Pane, right-click View Students and click Design View. The View Students macro is displayed in Design View, as shown in Figure 12. In Design View, you can add, move, or remove action rows. Figure 12 View Students macro in Design View 2. In the second action row, select Open Report from the dropdown list. 3. Click the Student Address Book report and drag it to the Report Name argument. The Student Address Book report is added as an argument, as shown in Figure 13.

Working with Macros 10 Figure 13 Student Address Book report added as an argument Student Address Book report in Navigation Pane Drag the report to the Report Name argument 4. In the second action row, click the row header in front of the action row you just created. Drag the row up and drop it above the first action row. The sequence of the action rows is changed, as shown in Figure 14. Figure 14 Sequence of action rows changed Row header 5. Right-click the second row header. Click Delete Rows on the dropdown menu. The second action row is deleted, removing the original action row from the macro.

Working with Macros 11 6. Click the Run button in the Tools group on the Ribbon. Because the macro was modified, a warning message is displayed stating that you must save the macro before you can run it. Click Yes. The macro is saved and the Student Address Book report is displayed, as shown in Figure 15. Figure 15 Student Address Book report displayed 7. SAVE your database. PAUSE. LEAVE the database open to use in the next exercise. You can edit a macro in three ways: insert an action row, move an action row, and remove an action row. If you modify a stand-alone macro as you did in the preceding exercise, every instance of the macro is also modified. For example, close the Student Address Book report. Open the Student Details form you modified earlier. Click the View Students button. The Student Address Book report is displayed. Deleting a Macro A macro might be replaced or it might not be needed. Clean up your database by deleting macros that are not used. Delete a Macro USE the database from the preceding exercise. If you closed and reopened the database, remember to enable the database content. 1. Close the View Students macro by closing the Macro Builder.

Working with Macros 12 2. In the expanded Navigation Pane, right-click the View Students macro and click Delete. A warning message is displayed, as shown in Figure 16. Figure 16 Warning message displayed when deleting a macro 3. Click Yes to close the dialog box and delete the macro. The macro is removed from the Navigation Pane. 4. In the Navigation Pane, double-click the Student Details form. The Student Details form is displayed. The View Students button is displayed in the form. 5. On the form, click View Students. An error message is displayed informing you that the macro cannot be found, as shown in Figure 17. Figure 17 Warning message displayed when deleted macro cannot be found 6. Click OK. The dialog box is closed. Close the Student Details form. 7. SAVE your database. STOP. CLOSE the database and Access. When you delete any Access object, use caution because some actions cannot be undone in Access. Do not delete a macro without also removing the macro from any forms or reports where it was inserted. Also, if you think you might need the macro in the future, do not delete it. You do not want to spend time and effort to recreate a macro you deleted.