In addition to creating objects, you can look at existing objects and determine their structures. When you retrieve structures, you iterate (loop) through collections. For example, you can iterate through the TableDefs collection to find all the tables, and then iterate through a specific TableDef object’s Fields collection to find information about the table’s fields.
As objects are appended to and deleted from collections, DAO usually keeps track of the collection. However, there are situations when DAO doesn’t know the current state of a collection. This occurs when:
If you want to make sure that you’re looking at the most up-to-date version of a collection, refresh the collection. This is done by using the Refresh method of the collection. The syntax for the Refresh method is:
Collection.Refresh
Collection is the name of the collection you want to refresh. For example, if your code needs a complete list of TableDef objects in the database, you may want to refresh the collection before using it. You can accomplish this with the following line of code, where dbs
is a pointer to the database:
dbs.TableDefs.Refresh
Use the Refresh method only when necessary because it may take time to refill the collection.