Databases Reference
In-Depth Information
In addition to the Container objects created by the Jet engine, Microsoft Access stores its
forms, reports, macros, and modules in the Containers collection. Hence, the Containers
collection also contains:
A Forms container object, containing information about all saved forms
A Reports container object, containing information about all saved reports
A Macros container object, containing information about all saved macros
A Modules container object, containing information about all saved modules
The Forms and Reports Container objects should not be confused with the Microsoft
Access collections of the same name (in the Access object model). In particular, the
former contains information about all saved objects, whereas the latter contains
information about all open objects.
To illustrate the aforementioned difference, create and save two forms in an Access
session, and make sure that only one form is open. Then run the code in Example 14-10,
which should report that the open form count is 1 but the saved form count is 2.
Example 14-10. A Containers collection example
Sub exaFormsContainer( )
Dim db As DATABASE
Dim frm As Form
Dim doc As Document
Set db = CurrentDb
Debug.Print "Opened form count: " & Forms.Count
For Each frm In Forms
Debug.Print frm.Name
Next
Debug.Print
Debug.Print "Saved form count: " & db.Containers!Forms.Documents.Count
For Each doc In db.Containers!Forms.Documents
Debug.Print doc.Name
Next
End Sub
Note that a user cannot create new or delete existing Container objects—they are
controlled by the Jet engine only. Put another way, there is no such thing as a user-
defined Container object. The properties of a Container object generally reflect security-
related issues, such as permission and user/group names. Container objects have no
methods.
Search WWH ::




Custom Search