From VBA to Access

When you open a module, whether it's a standard module or a class module, your screen will change radically. That's because the module opens in the Visual Basic editor, which is a separate program window from Access. In fact, if you look on the taskbar, you'll still see a taskbar button for Access. You can switch back and forth between Access and the editor just by clicking their respective taskbar buttons, as shown in Figure 1-6.

If the module you open contains any VBA code, that code is visible in the editor Code window, also shown in Figure 1-6. A class module might contain VBA code even if you never wrote a line of VBA code in your life because some of the control wizards in the form and report Design views automatically write VBA code for you behind the scenes. But let's not get ahead of ourselves.

The main thing to keep in mind here is that every time you open a module, you will end up in that Visual Basic editor. You'll discover how to use that program in upcoming chapters. For now, the most important thing to know is how to close it and get back to the more familiar Access program window. Here are two easy ways to close the Visual Basic editor and get back to the more familiar Access program window:

i Choose FileOClose and Return to Microsoft Office Access (see Figure 1-7). i Press Alt+Q.

Figure 1-6:

Move between the Visual Basic editor and Access.

Figure 1-6:

Move between the Visual Basic editor and Access.

Taskbar buttons Visual Basic editor

You can press Alt+F11 to switch back and forth between Access and the VBA editor at any time.

The Visual Basic editor closes, its taskbar button disappears, and you're returned to the Access program window.

Figure 1-7:

The VB editor File menu.

Mk'iosifft Visual Basic - VBA Dummies ■ [initCaps (Code)]

4

File | Edit View insert

Debug Run Tools Add-lns

Window Help

a

Save VBA Dummies

Ctrl+S

ü>

Import File...

Ctrl* M

■gf-l - «

Export File...

unction to fix i

Remove initCaps...

ät

Print...

Ctrl+P

ext, vbProperCa;

Close and^Return to Microsoft Office Access Alt+Q

Modulel ^

If Left(PCase, 4) =

"P.O." Then

PCase = "P.O." £ Mid(PCase, 5)

End If

0 0

Post a comment