O'Reilly logo

Access 2003 VBA Programmer's Reference by Armen Stein, Graham Seach, Teresa Hennig, Patricia Cardoza

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

2.2. VBA versus Macros in Access

Now that you've seen a little about how VBA works within Access you might be chomping at the bit to get started. However, there's one other scenario you should consider before jumping into Access programming without looking back: a macro. You can create a macro—a saved series of commands. Unlike in Word and Excel, where you can record your own macros, in Access you'll have to create the macro yourself, step-by-step. A macro enables you to perform a variety of operations within Access in response to the click of a command button or any other programmable event on a form or report.

If you've programmed in Word or Excel, you know that you can create a macro by starting the macro recorder and performing the desired steps. When you stop the macro recorder, all of the operations you've performed, from mouse clicks to keyboard strokes to menu selections, are recorded and saved in VBA code. You can then run the macro at a later time by selecting it from the Macros dialog box or in response to a keyboard or menu shortcut. Once you've recorded your macro, you can examine the VBA code behind the macro by simply choosing Edit from the Macros dialog box. This is one of the easiest ways to learn some VBA code within Word or Excel. For example, if you want to know the VBA code to insert three lines of text at the end of your Word document, just create a Word document start recording a macro, and type your three lines of text. You'll end up with code that looks ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required