

Events can also be triggered by factors outside of Access, such as system events, or by macros or procedures that are attached to other events. Each event property is associated with a specific event, such as clicking the mouse, opening a form, or modifying data in a text box. Objects (such as forms and reports) and controls (such as command buttons and text boxes) have various event properties to which you can attach macros or procedures. VBA code is contained in class modules (which are part of individual forms or reports and typically contain code just for those objects) and in modules (which are not tied to specific objects and typically contain "global" code that can be used throughout the database). Conversely, VBA code is referred to as VBA, code, a function, or a procedure. You should remember that in Access Help articles, Access macros are referred to as macros. The Macro Builder gives you a more structured interface than the Visual Basic Editor, enabling you to add programming to controls and objects without having to learn VBA code. Access macro actions represent only a subset of the commands available in VBA.

This can be confusing to Access users because, in Access, the term "macro" refers to a named collection of macro actions that you can assemble by using the Macro Builder. Note: Many Microsoft Office programs use the term "macro" to refer to VBA code.

For a simple operation, such as opening a report, you can use the Command Button Wizard to do all the work, or you can turn off the wizard and do the programming yourself. Programming, in this case, is the process of creating a macro or VBA procedure and then setting the command button's OnClick event property so that clicking the command button runs the macro or procedure. For example, suppose that you have created a form and a report, and you want to add a command button to the form that, when clicked, opens the report. In Access, programming is the process of adding functionality to your database by using Access macros or Visual Basic for Applications (VBA) code. Use the Command Button Wizard to perform common programming tasks Should I use macros or should I use VBA code?

This article helps orient you to the programming tools in Access. Eventually, you reach a point where you have to add some programming to automate certain processes and tie your database objects together. When you create a new database, you typically begin by creating several database objects such as tables, forms, and reports.
