Wiley Access 2007 VBA Programming For Dummies 978-0-470-04653-1 ユーザーズマニュアル

製品コード
978-0-470-04653-1
ページ / 12
Access does indeed have a ton of tools that let you create a database without
any programming. You could easily spend months or years just finding all the
things you can do in Access without writing any VBA code. Yet despite the
huge number of things you can do without programming, sometimes you
want your database to accomplish a task that’s not built into Access. That’s
where VBA comes in. When you want Access to perform a task that it doesn’t
already know how to perform, you write the steps to be performed in the
VBA programming language.
When you’re writing VBA code or just looking at some VBA code written by
someone else, Access doesn’t do anything. Access doesn’t start performing
the steps described by that code until Access executes the code. When you
write VBA code, you’re writing a set of instructions that Access can perform
at any time, over and over again.
The ability to use the same code over and over again is the key to automating
mundane tasks in Access. For example, if you use Access to print checks, you
might have to manually type the part of the check where you spell out the
amount, like “Ninety-two and 99/100 Dollars” for $92.99 because Access can’t
make that translation on its own. But if you could write some code to trans-
late a number like $92.99 into words, you wouldn’t need to type all those
dollar amounts. Access would just print the correct information as it prints
each check.
Seeing Where VBA Lurks
In an Access database, VBA code is stored in modules. Despite its fancy
name, a module is basically an electronic sheet of paper on which VBA code
is typed. A module in Access is either of these two types:
Standard: A page that contains VBA code that’s accessible to all objects
in the database. A standard module always exists in the Modules group
in the Navigation pane.
Class: A page of VBA code that’s attached to every form and report you
create. You can also create a class module that appears in the
Navigation pane.
12
Part I: Introducing VBA Programming 
Do, not die
Think of the term 
execute
in the sense of “to
carry out,” as when you execute a U-turn or
execute a procedure. Don’t think of 
execute
in
the sense of “terminate the life of.”
05_046531 ch01.qxp  1/16/07  10:31 PM  Page 12