Append Method (Professional Edition Only)
See Also Example
Adds a new object to a collection.
The Append method has the following parts:
collection A TableDefs, Indexes, or Fields collection.
newobject An object variable identifying a TableDef, Field, or Index object being appended. Must be of the same type as the members of the collection.
Use the Append method to add a new table, add a field to an existing table, or to add an index to a table. To create a new object variable, use the New keyword with the Dim or Set statement.
You must set the property values of newobject before you append the object to collection. Once an object is appended to a collection, the object's property values become read-only, except for the Value property of a Field object.
The addition of a new object occurs immediately, but you should use the Refresh method on any recordsets and any data control that may be affected by changes to the database structure.
Appending an object to a collection does not return an error except when appending a new TableDef to the TableDefs collection, when all objects and collections are validated. The validate operation verifies that the minimum object properties are complete and valid. If an object with the same name already exists in a collection, an error occurs. If any of the field names in the Fields property of an Index object are not valid, an error occurs.
Data Access Guide:
Chapter 2, "Database Management Using Visual Basic"
Append Method Example
The example defines a new field and appends it to a Fields collection.
Dim MyDB As Database, Fd As New Field
Const DB_TEXT = 10 ' Set field type constant.
Set MyDB = OpenDatabase("BIBLIO.MDB") ' Open a database.
Fd.Name = "Phone" ' Set field properties.
Fd.Type = DB_TEXT
Fd.Size = 15
MyDB.TableDefs("Authors").Fields.Append Fd ' Add field to collection.