Microsoft Access 2010 Bible

(Rick Simeone) #1

Chapter 2: Creating Access Tables


41



  1. Create the new table.

  2. Enter field names, data types, properties, and (optionally) descriptions.

  3. Set the table’s primary key.

  4. Create indexes for appropriate fields.

  5. Save the table’s design.


Generally speaking, some tables are never really finished. As users’ needs change, or the business
rules governing the application change, you might find it necessary to open an existing table in
Design view. This book, like most books on Access, describes the process of creating tables as if
every table you ever work on is brand-new. The truth is, however, that most of the work that you
do on an Access application is performed on existing objects in the database. Some of those objects
you’ve added yourself, while other objects may have been added by another developer at some
time in the past. However, the process of maintaining an existing database component is exactly
the same as creating the same object from scratch.

Tip
Just a quick note about modifying tables once they’re built: Adding a new field to a table almost never causes
problems. Existing queries, forms, and reports, and even VBA code, will continue using the table as before.
After all, these objects won’t reference the new field because the field was added after their creation.
Therefore, you can add a new field and incorporate the field where needed in your application, and everything
works as expected.


The trouble comes when you remove or rename a field in a table. Even with AutoCorrect turned on, Access
won’t update field-name references in VBA code, in control properties, and in expressions throughout the data-
base. Changing an existing field (or any other database object, for that matter) is always a bad idea. You should
always strive to provide your tables, fields, and other database objects with good, strong, descriptive names
when you add them to the database, instead of planning to go back later and fix them.


Tip
Many Access developers routinely turn off AutoCorrect. (Use the File tab to access the Backstage, selection
Options, then Current Database. In the Name Autocorrect Options, make sure Track Name AutoCorrect Info is
unchecked.) The AutoCorrect feature negatively affects performance because it constantly watches for name
changes in an application, and takes corrective action when needed. Furthermore, because AutoCorrect never
quite corrects all the names in an application, there is always more work to perform when you change the
name of a database object.


Begin by selecting the Create tab on the ribbon at the top of the Access screen. The Create tab
(shown in Figure 2.12) contains all the tools necessary to create not only tables, but also forms,
reports, and other database objects.

On the CD-ROM
The following examples use the Chapter02.accdb database found on this book’s CD.

Free download pdf