Document Object, Documents Collection

Document Object, Documents Collection

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
DataAccessPage DataAccessPages Saved DataAccessPage
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 (DAO). 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 DAO 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, Category, and Hyperlink Base. 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 haven't 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, search the Help index for "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.