Datasheet
Book VIII
Chapter 1
What the Heck
Is VBA?
Discovering Code as You Go
587
Closing the Visual Basic Editor
When you’re done working in the Visual Basic Editor, you can close it by
using whichever of the following techniques is most convenient for you:
✦ Choose File➪Close and return to Microsoft Access from the Visual Basic
Editor main menu.
✦ Click the Close button in the upper-right corner of the Visual Basic
Editor program window.
✦ Right-click the Visual Basic Editor button on the taskbar, and then
choose the Close option from the shortcut menu.
✦ Press Alt+Q.
Access continues to run even after you close the Visual Basic Editor window.
Discovering Code as You Go
Most beginning programmers start by working with code they pick up else-
where, such as code generated by code wizards, or code copied from a Web
site. You can also create VBA code, without writing it, by converting any
macro to VBA code.
Converting macros to VBA code
Any macro you create in Access can be converted to VBA code. Converting
macros to code is easier than writing code from scratch. For example, say
you need to write some code because a macro can’t do the job. But a macro
can do 90 percent of the job. If you create the macro and convert it to VBA
code, 90 percent of your code is already written. You just have to add the
other ten percent (which is especially helpful if you can’t type worth beans).
See Book VI, Chapter 1 for how macros work and how to create them.
As an example, suppose you click the Create tab, click the last Other button,
and then choose Macros, as in Figure 1-15, to create a new macro.
Then you create your macro. The macro can be as large or as small as you
want. Figure 1-16 shows a small simple example of a macro that shows a mes-
sage on the screen. After you create your macro, close and save it. For this
example, say I saved the macro in Figure 1-16 with the name
TinyMacro.
38_036494 bk08ch01.qxp 11/17/06 8:34 AM Page 587