WORKING WITH MACROS CHAPTER 10 WORKING WITH MACROS.

Slides:



Advertisements
Similar presentations
1 After completing this lesson, you will be able to: Create a database. Create a table using the Table Wizard. Create and modify a table in Design view.
Advertisements

Benchmark Series Microsoft Access 2010 Level 1
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Excel Project 7 Using Macros and Visual Basic for Applications (VBA) with Excel.
Using Macros and Visual Basic for Applications (VBA) with Excel
Developing an Excel Application
Guide to Oracle10G1 Introduction To Forms Builder Chapter 5.
Microsoft Office 2007 Access Chapter 2 Querying a Database.
Chapter 1 Databases and Database Objects: An Introduction
Exploring Microsoft Access Chapter 8 Creating More Powerful Applications: Introduction to VBA By Robert T. Grauer Maryann Barber.
Automating Tasks With Macros
Exploring Office Grauer and Barber 1 Creating More Powerful Applications: Introduction to VBA(Wk9)
Customizing Word Microsoft Office Word 2007 Illustrated Complete.
Automating Tasks With Macros. 2 Design a switchboard and dialog box for a graphical user interface Database developers interact directly with Access.
With Microsoft Access 2010© 2011 Pearson Education, Inc. Publishing as Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Access.
Macros Tutorial Week 20. Objectives By the end of this tutorial you should understand how to: Create macros Assign macros to events Associate macros with.
MsgBox Function Displays one of Visual Basic’s predefined dialog boxes, which contains a message, one or more command buttons, and an icon After displaying.
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Word Project 8 Working with Macros and Visual Basic for Applications (VBA)
COMPREHENSIVE Excel Tutorial 8 Developing an Excel Application.
Access Tutorial 10 Automating Tasks with Macros
Chapter 9 Macros, Navigation Forms, PivotTables, and PivotCharts
Chapter 2 Querying a Database
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Chapter 3 Maintaining a Database
Chapter 2 Querying a Database MICROSOFT ACCESS 2010.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
Project 9 Using Visual Basic for Applications (VBA) to Customize and Automate Excel Jason C. H. Chen, Ph.D. Professor of Management Information Systems.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. WORD 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 22 Macros.
Copyright 2007, Paradigm Publishing Inc. EXCEL 2007 Chapter 7 BACKNEXTEND 7-1 LINKS TO OBJECTIVES Record & run a macro Record & run a macro Save as a macro-
Automating Tasks with Visual Basic. Introduction  When can’t find a readymade macro action that does the job you want, you can use Visual Basic code.
© Paradigm Publishing, Inc Access 2010 Level 2 Unit 2Advanced Reports, Access Tools, and Customizing Access Chapter 7Automating, Customizing, and.
Chapter 1 Databases and Database Objects: An Introduction
Chapter 6 Advanced Report Techniques
Chapter 6 Generating Form Letters, Mailing Labels, and a Directory
Microsoft Office Access 2003 Số tiết: 30 tiết lý thuyết 60 tiết thực hành Giáo viên: Từ thị Xuân Hiền.
Automating Database Processing Chapter 6. Chapter Introduction Design and implement user-friendly menu – Called navigation form Macros – Automate repetitive.
Office 2003 Advanced Concepts and Techniques M i c r o s o f t Access Project 6 Switchboards, PivotTables, and PivotCharts.
Microsoft Visual Basic 2005 ENRICHMENT CHAPTER Visual Studio Tools for Office.
Office Management Tools II Ms Saima Gul.  When you create your tables, you should assign each table a primary key—one or more fields whose contents are.
Microsoft Office 2007 Access Chapter 6 Using Macros, Switchboards, PivotTables, and PivotCharts.
Intro to Excel - Session 7.31 Tutorial 7 - Session 7.3 Developing an Excel Application.
XP 1 Microsoft Access 2003 Introduction To Microsoft Access 2003.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Program Design and Coding
Microsoft Visual Basic 2012 CHAPTER THREE Program Design and Coding.
Automating Database Processing
® Microsoft Office 2010 Access Tutorial 3 Maintaining and Querying a Database.
Key Applications Module Lesson 21 — Access Essentials
Tutorial 51 Programming Structures Sequence - program instructions are processed, one after another, in the order in which they appear in the program Selection.
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Access Project 7 Advanced Report and Form Techniques.
Exploring Microsoft Access Chapter 8 Creating More Powerful Applications: Introduction to VBA.
Microsoft Access 2013 ®® Tutorial 10 Automating Tasks with Macros.
Microsoft Access 2010 Chapter 8 Advanced Form Techniques.
XP Chapter 2 Succeeding in Business with Microsoft Office Access 2003: A Problem-Solving Approach 1 Building The Database Chapter 2 “It is only the farmer.
XP New Perspectives on Microsoft Office FrontPage 2003 Tutorial 7 1 Microsoft Office FrontPage 2003 Tutorial 7 – Creating and Using Templates in a Web.
Lesson 01: Introduction to Database Software. At the end of this lesson, students should be able to: State the usage of database software. Start a database.
Office 2003 Advanced Concepts and Techniques M i c r o s o f t Access Project 6 Creating an Application System Using Macros, Wizards, and the Switchboard.
® Microsoft Access 2010 Tutorial 10 Automating Tasks with Macros.
XP New Perspectives on Microsoft Office Access 2003 Tutorial 10 1 Microsoft Office Access 2003 Tutorial 10 – Automating Tasks With Macros.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
XP New Perspectives on Microsoft Office FrontPage 2003 Tutorial 7 1 Microsoft Office FrontPage 2003 Tutorial 8 – Integrating a Database with a FrontPage.
1 Fields Sacramento City College Engineering Design Technology.
INTRODUCTION TO ACCESS. OBJECTIVES  Define the terms field, record, table, relational database, primary key, and foreign key  Create a blank database.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 6 Looping and Multiple Forms.
Chapter 10 Using Macros, Controls and Visual Basic for Applications (VBA) with Excel Microsoft Excel 2013.
Chapter 11 Enhancing an Online Form and Using Macros Microsoft Word 2013.
Excel Tutorial 8 Developing an Excel Application
Using Macros, Switchboards, PivotTables, and PivotCharts
Chapter 7 Advanced Form Techniques
Tutorial 10 Automating Tasks with Macros
Microsoft Excel 2007 – Level 2
Presentation transcript:

WORKING WITH MACROS CHAPTER 10 WORKING WITH MACROS

1. Introduction A macro helps you perform routine tasks by automating them Record a single macro that does the entire task all at once instead of manually performing a series of time-consuming, repetitive actions. A macro is a set of one or more actions that perform a particular operation

2. Creating and Running a Macro Simple macros that automate a single task, such as opening a form or report, are simple to create Complicated macros with several steps or procedures require planing. Before creating a complicated macro, identify what the macro will do and the individual actions that are required to complete this operation.

2. Creating and Running a Macro In the database window, click the macros icon in the objects bar and click the new button. In action column, select the action you want the macro to perform. Specify any required arguments for the action in the action arguments area. Cick the save button on the toolbar

2. Creating and Running a Macro

Click the macros icon in the objects bar and double-click the macro you want to run or click run button

3. Editing a Macro Macros can contain many actions to automate even the most complicated tasks Each action appears in its own row and is executed in the order in which it appears in the Macro window, from top to bottom. To modify a macro: ◦ In the database window, click the macros icon in the objects bar, select the macro you want to edit, and click the design button.

4. Working with Macro Groups A macro group stores several related macros together in a single macro object To create a macro group, give each macro in the macro group its own unique name by entering the macro names in the Macro Name column (by clicking the Macro Names button on the toolbar). When combine two or more macros within the same macro group, must run them separately, by referring to the macro group name, followed by the macro name

4. Working with Macro Groups

To run a macro in a macro group: Select tools  macro  run macro from the menu. Click the macro name list arrow, select the macro you want to run, and click ok

5. Assigning a Macro to an Event To assign a macro to a control on a form or report: Open the form or report in design view. Click the control to which you want to assign the macro and click the properties button on the toolbar.

5. Assigning a Macro to an Event Click the event tab and click in the box for the type of event you want to assign to the macro. Select the macro you want to assign to the event. Close the properties dialog box and save the form or report.

5. Assigning a Macro to an Event EventDescription Before Update Macro or function that runs when data in a field or record is changed but before the changes are actually saved to the database. Often used to validate data. After Update Macro or function that runs when data in a field or record is changed and is saved to the database.

5. Assigning a Macro to an Event On Change Macro or function that runs when the contents of a text box or combo box changes or when you move from one page to another page in a tab control. On Enter Macro or function that runs when a control first gets the focus. The Enter event occurs before the focus moves to a particular control. You can use an Enter macro or event procedure to display instructions when a form or report first opens. On Exit Macro or function that runs when a control loses focus (is deselected) on the same form.

5. Assigning a Macro to an Event On Got Focus Macro or function that runs when a control gets the focus (is selected). On Lost Focus Macro or function that runs when a control loses the focus (is deselected). On Click Macro or function that runs when a control is clicked. On Dbl Click Macro or function that runs when a control is double-clicked.

5. Assigning a Macro to an Event On Mouse Down Macro or function that runs when the user presses the mouse button. On Mouse Move Macro or function that runs when the user moves the mouse over a control. On Mouse Up Macro or function that runs when the user releases the mouse button. On Key Down Macro or function that runs when the user presses a key on the keyboard. On Key Up Macro or function that runs when the user releases a key on the keyboard. On Key Press Macro or function that runs when the user presses an ANSI key on the keyboard.

6. Creating Conditional Expressions The macro condition states this effectively: If this condition is true, run this action. If it is not true, go to the next action, if any. Normally, a condition applies only to the action on the same row in the macro sheet. If the condition isn’t met, the next action is executed. To continue the condition to the next action, enter an ellipsis (…) in the Condition column of the next row. You can apply the condition to several sequential actions

6. Creating Conditional Expressions

To add the Condition column to the macro sheet, click the Conditions button or choose View | Conditions. Type the logical expression for the condition in the row with the action you want to carry out if the condition is True. If you want to use the Expression Builder to help with the expression, right-click in the Condition column and choose Build from the shortcut menu.

7. Some Common Uses for Macros Displaying a Message Box MsgBox display warnings, alerts, and other information MessageEnter the text of the message you want displayed when the Beepsound a beep signal when the message TypeSets the type of message box, each of which displays a TitleText that displays in the message box title bar

7. Some Common Uses for Macros Setting Values and Properties ◦ Set the value of a control based on the value of another control in the same or a different form or report Many of the properties of forms, reports, and controls can be set by running a macro. For example, you can hide a control from view on the form or disable it so the user can’t enter data in it.

7. Some Common Uses for Macros The MsgBox function is similar to the MsgBox action with the exception that the function returns one of seven different values, depending on which button the user clicks in the message box The MsgBox function displays a dialog box containing the message and waits for the user to click a button indicating the user’s choice The MsgBox function has three main arguments; only the first is required

7. Some Common Uses for Macros ◦ Prompt is a string expression displayed in the dialog box. ◦ Button is a number equal to the sum of three values that specify the visual characteristics of the message box ◦ Title is a string expression displayed in the dialog box title bar

7. Some Common Uses for Macros You can also specify which of the buttons is the defaultYou can also specify which of the buttons is the default ValueButtons To Display: 0Display only the OK button. 1Display the OK and Cancel buttons. 2Display the Abort, Retry, and Ignore buttons. 3Display the Yes, No, and Cancel buttons. 4Display the Yes and No buttons. 5Display the Retry and Cancel buttons.

7. Some Common Uses for Macros Icons To Display: 0Display no icon. 16Display the Critical Message icon. 32Display the Warning Query icon. 48Display the Warning Message icon. 64Display the Information Message icon.

7. Some Common Uses for Macros When you use the MsgBox function in a macro condition, you can compare the returned value to a specific number and carry out the action if the comparison is True ButtonReturned Value OK1 Cancel2 Abort3 Retry4 Ignore5 Yes6 No7

8.Creating an AutoExec Macro You can create a special macro that runs when you first open a database. The AutoExec macro can carry out such actions as open a form for data entry, display a message box. All you need to do is create the macro with the actions you want carried out at startup and save it with the name AutoExec. Adatabase can have only one macro named AutoExec

9. Macro Action Reference (tự tham khảo)