1 / 28

CHAPTER 10 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.

jason
Download Presentation

CHAPTER 10 WORKING WITH MACROS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CHAPTER 10WORKING WITH MACROS

  2. 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

  3. 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.

  4. 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

  5. 2. Creating and Running a Macro

  6. 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

  7. 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.

  8. 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

  9. 4. Working with Macro Groups

  10. 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

  11. 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.

  12. 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.

  13. 5. Assigning a Macro to an Event

  14. 5. Assigning a Macro to an Event

  15. 5. Assigning a Macro to an Event

  16. 5. Assigning a Macro to an Event

  17. 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

  18. 6. Creating Conditional Expressions

  19. 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.

  20. 7.Some Common Uses for Macros • Displaying a Message Box

  21. 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.

  22. 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

  23. 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

  24. 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

  25. 7. Some Common Uses for Macros

  26. 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

  27. 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

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

More Related