Creating and Modifying Tables

In Chapter 2, “Introducing Data Access Objects,” you were introduced to the concept of using DAO to add a new table to a database by appending a Field object to the Fields collection of a TableDef object, and then appending that TableDef object to the TableDefs collection of the database. In the same way, you can add field-level and table-level validation rules, or specify indexes and inter-table relationships entirely through DAO code or SQL DDL statements.

When you use the Microsoft Access user interface to add fields to a table or to specify validation rules and default values in a property sheet, Microsoft Access is using DAO behind the scenes to tell the underlying Microsoft Jet database engine how to build or modify your table.

Anything that a user can do through the Microsoft Access user interface can be done with code. In some cases, properties and capabilities of Microsoft Jet that are available to you as a DAO programmer are not available through Microsoft Access. For example, through DAO you can specify fixed-length text fields for your tables. Microsoft Access allows only variable-length fields.