Download presentation
Presentation is loading. Please wait.
1
DB Implementation: MS Access Macros
2
Programming in MS Access
Modules An organized collection of Visual Basic for Application (VBA) code More flexible and powerful than macros, but less secure Macros A named set of actions that perform operations/tasks e.g. open/close a form, print a report, set value of a control Tool to automate tasks and extend functionalities without programming Macro actions/functions = subset of commands available in VBA Embedded Macro vs Standalone Macro Command Button Wizard (embedded macro) To perform Common Tasks Macro Builder (standalone macro) Create/Modify Macros. Build a list of actions to perform by selecting from list of actions Database Design
3
Access Macros: Macro Builder
Creating a standalone macro using a macro builder (Tab) Create → (Group) Macros & Code → click Macro Select an action from the dropdown menu (e.g., Openform) creation: CUSTOMER table multi-table query: PRODUCT+SUPPLIER qrySensless, qrySensible Database Design
4
Access Macros: Macro Builder
Select the form name to open. Click “Save” icon and enter a macro name. creation: CUSTOMER table multi-table query: PRODUCT+SUPPLIER qrySensless, qrySensible Database Design
5
Access Macros: Macro Builder
Click “Run” icon to test the macro. Select the saved macro name for the “On Click” event of the command button. creation: CUSTOMER table multi-table query: PRODUCT+SUPPLIER qrySensless, qrySensible Database Design
6
Access Macros: Macro Builder
Creating an embedded macro using a macro builder Click “…” icon for an event of the command button & select “Macro Builder” Follow the same procedure as a standalone macro. creation: CUSTOMER table multi-table query: PRODUCT+SUPPLIER qrySensless, qrySensible Database Design
7
Access Macros: Elements
Event Property Sheet 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 Macro Builder What the macro does e.g. load/close/delete object, set field/control value Action Arguments (properties) What action applies to e.g. frmEmployee Conditions (i.e., If) Conditions that must be true for the macro to run e.g. IsNull(Forms![frmEmployee]![Status]) creation: CUSTOMER table multi-table query: PRODUCT+SUPPLIER qrySensless, qrySensible Database Design
8
Access Macros: Events Event is the reason the macro “fires” or runs.
A macro’s execution should be triggered by a specific event Successful macro use depends on attaching to appropriate events good macro design. 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 Set the appropriate Event Property of the control to the name of the macro that will perform desired actions. creation: CUSTOMER table multi-table query: PRODUCT+SUPPLIER qrySensless, qrySensible Database Design
9
Access Macros: Macro Builder
creation: CUSTOMER table multi-table query: PRODUCT+SUPPLIER qrySensless, qrySensible Database Design
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.