>

Document Object

Description

A Document object includes information about one instance of a type of object. The object can be a database, saved table, query, or relationship.

Remarks

Each Container object has a Documents collection containing Document objects that describe instances of built-in Container types. The following table lists the type of object each Document describes, the name of its Container object, and what type of information Document contains.

Document Container Contains information about
Database Databases Containing database
Table or query Tables Saved table or query
Relationship Relations Saved relationship
Note

Don't confuse the particular types of Container objects with the collection types of the same name. For example, the Databases Container object refers to all saved objects of the specified type, but the Databases collection refers only to open objects of the specified type.

Because a Document object corresponds to an existing object, you can't create new Document objects or delete existing ones. Using the properties of an existing Document object, you can:

You can refer to a Document object by its Name property setting using this syntax:

cntApplication.Documents("name")

Properties

AllPermissions Property; Container Property; DateCreated, LastUpdated Properties; Name Property; Owner Property; Permissions Property; UserName Property.

See Also

User Object; Appendix, "Data Access Object Hierarchy."

Specifics (Microsoft Access)

In addition to the Document objects defined by the Microsoft Jet database engine, the following Document objects are defined by Microsoft Access.

Document Container Contains information about
     
Form Forms Saved form
Macro Scripts Saved macro
Module Modules Saved module
Report Reports Saved report
SummaryInfo Databases Database document summary
UserDefined Databases User-defined properties

The Document objects defined by Microsoft Access are Microsoft Access database objects, not data access objects. These Document objects provide the Jet database engine with information about Microsoft Access objects. The Jet database engine uses this information to implement security on Microsoft Access database objects in the same way it does for data access objects.

The Documents collection of a Container object contains Document objects representing the individual objects of the type described by the Container object. For example, the Forms Container object has a Documents collection that might include a Document object corresponding to a form named Orders.

Microsoft Access defines two Document objects in the Databases Container object — SummaryInfo and UserDefined.

The SummaryInfo Document object provides programmatic access to document summary properties — including Title, Subject, Author, Keywords, Comments, Manager, Company, and Category. You can also set these properties on the Summary tab of the Database Properties dialog box, available by clicking Database Properties on the File menu.

To set these properties in Visual Basic, you must create them and append them to the Properties collection of the SummaryInfo Document object if they have not already been set in the Database Properties dialog box. Once a property has been created, you must explicitly refer to the Properties collection to set it. In the following example, doc is an object variable pointing to the SummaryInfo Document object.


doc.Properties!Title = "Northwind Traders"
For more information on creating and setting Microsoft Access-defined properties, see the topics for the Property object and CreateProperty method.

The UserDefined Document object provides programmatic access to user-defined properties defined on the Custom tab of the Database Properties dialog box. You can also create these properties in Visual Basic and append them to the Properties collection of the UserDefined Document object.

Note

Don't confuse properties defined in the Properties collection of a Database document with properties defined in the Properties collection of a Database object. You can create user-defined properties in either Properties collection, but only those defined on the SummaryInfo or UserDefined Document objects can be set from the Database Properties dialog box.

You can use Document objects to establish and enforce permissions for individual Microsoft Access database objects. To set permissions for a Document object, set the UserName property of the Document object to the name of an existing User or Group object. Then set the Permissions property for the Document object.

Note

Don't confuse the particular types of Container objects with the collection types of the same name. The Forms and Reports Container objects each contain Documents collections, which include individual Document objects representing each saved form or report. The Forms and Reports collections refer only to open forms or reports.

Example

See the Container object example.

Example (Microsoft Access)

The following example prints the name of each Form Document object in the current database and the date it was last modified.


Sub DocumentModified()
    Dim dbs As database, ctr As container, doc As Document

    ' Return Database variable pointing to current database.
    Set dbs = CurrentDb
    ' Return Container variable pointing to Forms container.
    Set ctr = dbs.Containers!Forms
    ' Enumerate through Documents collection of Forms container.
    For Each doc In ctr.Documents
        ' Print Document object name and value of LastUpdated property.
        Debug.Print doc.Name; "    "; doc.LastUpdated
    Next doc
End Sub