Microsoft Access 2010 Bible

(Rick Simeone) #1

1049


CHAPTER


Using Access Macros


IN THIS CHAPTER


Getting acquainted with
macros

Working with multi-action
macros

Using submacros for actions
that are frequently required

Making decisions with
conditions

Using temporary variables

Handling errors and
debugging your macros

Understanding embedded
macros

Comparing macros to VBA

M


acros have been a part of Access since the beginning. As Access
evolved as a development tool, the Visual Basic for Applications
(VBA) programming language became the standard in automating
Access database applications. Macros in previous versions of Access lacked
variables and error handling, which caused many developers to abandon
macros altogether. Access 2010 has these capabilities (added in Access
2007), which make macros a better alternative to VBA than in previous ver-
sions. If it’s a slow day and you don’t feel like writing VBA code, or if you
aren’t a VBA guru but you still want to customize the actions that your appli-
cation executes, then building structured macros is the answer.


On the CD-ROM


This chapter uses a database named Chapter30.accdb. If you haven’t
already copied it onto your machine from the CD, you’ll need to do so now. This
database contains the tables, forms, reports, and macros used in this chapter.


An Introduction to Macros


A macro is a tool that allows you to automate tasks in Access. It’s different
from Word’s Macro Recorder, which lets you record a series of actions and
play them back later. (It’s also different from Word in that Word macros are
actually VBA code, whereas Access macros are something very different.)
Access macros let you perform defined actions and add functionality to your
forms and reports. Think of macros as a simplified, step-wise programming
language. You build a macro as a list of actions to perform, and you decide
when you want those actions to occur.

Free download pdf