Lesson10.2.Editing a Macro


Lesson 10.2. Editing a Macro

Figure 10-2. The mcrEmployees macro with two additional actions.


Figure 10-3. A message boxthe result of the MsgBox action.


Some Microsoft Access tasks require several steps. For example, a particular task might require you to (1) open a form, (2) select a specific record, (3) select a specific field in that record, and then (4) copy the information in that field to the Windows clipboard. Macros can contain as many actions as necessary to automate even the most complicated tasks. Each action appears in its own row and is evaluated and executed in the order in which it appears in the Macro window, from top to bottom.

In this lesson you will edit the macro you created in the previous lesson to change its arguments and add some more steps or actions.

  1. Select the mcrEmployees macro and click the Design button.

    The mcrEmployees macro opens in Design view. Let's add two more actions to this macro.

  2. Click the Action cell just below the OpenForm action, click the list arrow, scroll down the list, and select Maximize.

    When you run the macro, the Maximize action will maximize the window so that it fills the entire Microsoft Access window. Because the Maximize action is so simple and straightforward, it doesn't have any additional arguments.

    Let's add another action to the mcrEmployees macro.

  3. Click the Action cell just below the Maximize action, click the list arrow, scroll down, and select MsgBox.

    When you run the macro, the MsgBox action will display a message box that contains a warning or an informational message. The Message argument is the most important argument for the MsgBox action because it determines the text that is displayed in the message box.

  4. Click the Message argument box and type Please make sure that you remember to add the employee's phone number!.

    There are several other arguments you may want to specify for the MsgBox action, such as the type of icon that is displayed in the message box (None, Critical, Warning?, Warning!, or Information) and the text that is displayed in the title bar of the message box.

  5. Click the Type argument box, click the list arrow, and select Information. Click the Title argument box and type Notice.

    Your macro should look like the one shown in Figure 10-2. Remember that actions are evaluated and/or executed in the order in which they appear, so the mcrEmployees macro will (1) open the frmEmployees form, (2) maximize the form window, and (3) display the message box.

  6. Click the Save button on the toolbar.

    That's all the we need to do for this lesson.

  7. Close the macro window.

    Let's test the macro.

  8. Double-click the mcrEmployees macro.

    Sure enough, the mcrEmployees macro (1) opens the frmEmployees form, (2) maximizes the form window, and (3) displays the message box, as shown in Figure 10-3.

  9. Click OK to close the message box, then click the Close button to close the frmEmployees form.

     

QUICK REFERENCE

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.




CustomGuide Inc - Access 2003 Personal Trainer
Access 2003 Personal Trainer (Personal Trainer (OReilly))
ISBN: 0596009372
EAN: 2147483647
Year: 2005
Pages: 209

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net