Unformatted text preview:

Create a MacroAdd ActionsRearrange ActionsDelete an ActionSetting ArgumentsSave a MacroRunning a MacroCreating a Macro GroupReferring to Control Names (Values and Properties) in ExpressionsUsing Conditions in MacrosConditionResultsConditionActionCommentFinding Problems in MacrosAction Failed Dialog BoxResponding to Events on FormsUsing a Command Button to Open a FormSetting ValuesNavigating Between ControlsValidating DataMIS 441: User Interface Design, Prototyping, and EvaluationProfessor Matt ThatcherMicrosoft Access: UI Interaction with Macros What Are Macros?A macro is a bundle of easy-to-use code that automatically carries out commonly performed tasks. Each task you want MA to perform is called an action. MA provides a list of actions for you to select from to create a macro. When you run the macro MA carries out the actions in the sequence that they are listed. Macros can help do the following:- Make your forms and reports work together: Macros allow you to create command buttons that perform actions like opening and closing forms, printing, saving, etc..- Set values of controls: Using macros you can set the value of a control on a form to the result of a calculation or to the value from another form (or table).- Set Properties of Forms, Reports, and Controls: You can use macros to set most form, report, and control properties. For example, you can use a macro to “hide” a form when you do not need to see it on the screen but you still need to use the data on the form. In addition, you can use a macro to changethe format of a control.- Ensure Data Accuracy: Macros are ideal for specialized data handling and validation on forms (more complex data handling and validation than that provided by the ValidationRule property). You can use a macro to respond to different kinds of data in a control with different messages.- Automate Data Transfers: You can use a macro to automatically import or export data between different file formats (e.g., Excel Spreadsheet)- Create Your Own Custom Working Environment: You can use a macro to automatically open a group of forms, tables, queries, and reports when you open your database. In addition, you can use macros tocustomize menu bars for your form.Create a MacroMacro tab  New  Opens a Macro window where you can select Actions you want to include in the macro and Comments that document the purpose of the actions.The upper part of the Macro window allows you to add actions. The lower-left part of the window allows you to specify arguments for each action. The lower -right part of the window provides descriptions of an action or an action argument.Add ActionsSimply select from the list of 49 actions and set the arguments presented by MA.Rearrange ActionsSelect actions by clicking the row selector to the left of the Action name  Then click on the row selector again anddrag it to a new positionDelete an ActionSelect the action by clicking the row selector  Press the DEL keySetting ArgumentsThe descriptions section of the Macro window provides great help for setting arguments.Save a MacroYou must save a macro before you run it. Try to save it under a very descriptive name.Running a MacroYou can run a macro from the macro window (or from other windows in the database), from another macro, or in response to an Event that occurs in a form or a report.- To run a macro from the macro window: With the macro open go to Macro menu  Run (or click the Run button on the toolbar). Please note that you can also Step through a macro line-by-line to help debug your macros.- To run a macro from another macro: Add the RunMacro action to your macro  Set the MacroName argument to the name of the macro you want to run.- To run a macro in response to an event that occurs in a form or a report: Set the appropriate Event propertyto the name of the macro that you want to run.Creating a Macro GroupIt may be convenient to group a number of related macros in one macro window. A Macro Group is a set of 1 or more macros that appear in the same window. The individual macros run independently of one another. Say that you have 6 Command Buttons on a form, each of which opens a different form. Instead of having 6 separate macro sheets in your database (one for each button) you can create a Macro Group that contains a macro for each button. This way you will have all of the macros related to the form together in 1 convenient document.To create a Macro Group you need to use Macro Name.While in the Macro window go to the View menu  Macro Names  Type a macro name for each set of actions that make up a macro.Referring to Control Names (Values and Properties) in ExpressionsYou may want to refer to the value of a control in a macro (e.g., in the SetValue action discussed later in this tutorial). You should use the following syntax to refer to controls in an expression in a macro:Forms![formname]![controlname]Reports![formname]![controlname]Remember to use the brackets and the exclamation points. The following is an example:Forms![Suppliers]![SupplierID] refers to the SupplierID control on the open Suppliers form (the form must be open for MA to have access to its controls)If, in an expression, you are referring to a control which is on the form or report from which the macro was run you can use the following short cut syntax:[controlname]e.g., [SupplierID] refers to the SupplierID control on the form or report from which the macro was run.You can refer to the value of a form control and the value of most form, report, and control properties.Forms![Suppliers]![SupplierID].Visible refers to the Visible property of the SupplierID control on the open Suppliers form.2Tip: When in the Macro window look at the SetValue action and its arguments. You can use the Expression Builder (…) to help you enter expressions for the Item and Expression arguments of the SetValue action. You can also use the Expression Builder for the WhereCondition argument for the OpenForm and OpenReport actions.Using Conditions in MacrosYou may want to carry out an action or series of actions in a macro only if a particular Condition is true. For example, if you are using a macro to validate data in a form you might want to display one message in response to one set of values entered in a control and another message in response to a different set of values.A Condition is a logical expression. The macro follows different paths depending on whether the


View Full Document
Download Microsoft Access
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Microsoft Access and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Microsoft Access 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?