See Also Properties
An object in a database that defines the structure of a table. In contrast, a Table is the physical container of the data in a Database.
With a data control, you can examine the structure of a table using the TableDefs collection of the data control's Database property. For example, you can read the Count property of the Fields collection to determine how many Field objects are in a Table, and then read the Field names. For example, the following code prints all Field names in a TableDef:
For I = 0 to Data1.Database.TableDefs("Publishers").Fields.Count - 1
A table is stored in a database and has a name that is recognized by the database. A TableDef has a Name property that is the name of the table defined by the TableDef. The Name property of a TableDef is not the same as the name of an object variable to which it is assigned. Unlike forms and controls, the Name property of a TableDef object is available at run time.
The default collection of a Database is the TableDefs collection, and the default collection of a TableDef and all recordsets The default property of a TableDef is the Name property. You can simplify your code by taking advantage of these defaults. For example, both of the following code lines print the name of the first table in the TableDefs collection: is the Fields collection.
In the Professional Edition, you can create an object variable of type TableDefs as well as type TableDef. You can make changes in the structure of a table, and even create new tables in a database.
To create a Table in a Database ready for new records
1. Create a New TableDef.
2. Set its properties.
3. Create New Field objects, set their properties, and add them to the Fields collection of the TableDef with the Append method.
4. Use the Append method to add the new TableDef to the TableDefs collection of the Database.