DB Implementation MS Access Macros Programming in MS

DB Implementation: MS Access Macros

Programming in MS Access Modules u u An organized collection of Visual Basic for Application (VBA) code More flexible and powerful than macros, but less secure Macros u A named set of actions that perform operations/tasks · u Tool to automate tasks and extend functionalities without programming · u Macro actions/functions = subset of commands available in VBA Command Button Wizard · u e. g. open/close a form, print a report, set value of a control To perform Common Tasks Macro Builder · Database Design Build a list of actions to perform by selecting from list of actions 2

Access Macros: Elements Event u The reason the macro “fires” or runs. · i. e. , the trigger for a macro execution · e. g. , a form control gaining/losing focus, mouse click/movement Action u What the macro does · Action Arguments (properties) u What action applies to · e. g. load/close/delete object, set field/control value e. g. frm. Employee Conditions u Conditions that must be true for the macro to run · Database Design e. g. Is. Null(Forms![frm. Employee]![Status]) 3

Access Macros: Events Event is the reason the macro “fires” or runs. u u A macro’s execution should be triggered by a specific event Successful macro use depends on attaching to appropriate events · good macro design. · u Example · After Update vs. Lost Focus event → → loss of focus can occur without data entry or edit for data entry trigger, use “After Update” event Associating Events and Macros u Set the appropriate Event Property of the control to the name of the macro that will perform desired actions. Database Design 4

Access Macros: Grouping Simple/Embedded Macro u u A single macro Actions are executed sequentially from top to bottom Macro Group u u Related macros grouped together in a macro object Individual macros in a macro group are referenced by · Macro. Group. Name. Macro. Name → e. g. mcr. Open. Close. GRP. Close. Im. Open S 511 Session 9, IU-SLIS 5
- Slides: 5