Description
A Document object includes information about one instance of an object. The object can be a database, saved table, query, or relationship (Microsoft Jet databases only).
Remarks Each Container object has a Documents collection containing Document objects that describe instances of built-in objects of the type specified by the Container. 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 | Saved database |
Table or query | Tables | Saved table or query |
Relationship | Relations | Saved relationship |
See Also User object.
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 |
doc.Properties!Title = "Northwind Traders"
For more information on creating and setting Microsoft Access–defined properties, see the Property object and the 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
This example enumerates the Documents collection of the Tables container, and then enumerates the Properties collection of the first Document object in the collection.
Sub DocumentX()
Dim dbsNorthwind As Database
Dim docLoop As Document
Dim prpLoop As Property
Set dbsNorthwind = OpenDatabase("Northwind.mdb")
With dbsNorthwind.Containers!Tables
Debug.Print "Documents in " & .Name & " container"
' Enumerate the Documents collection of the Tables
' container.
For Each docLoop In .Documents
Debug.Print " " & docLoop.Name
Next docLoop
With .Documents(0)
' Enumerate the Properties collection of the first.
' Document object of the Tables container.
Debug.Print "Properties of " & .Name & " document"
On Error Resume Next
For Each prpLoop In .Properties
Debug.Print " " & prpLoop.Name & " = " & _
prpLoop
Next prpLoop
On Error GoTo 0
End With
End With
dbsNorthwind.Close
End Sub
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 reference to current database.
Set dbs = CurrentDb
' Return referenct 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
Set dbs = Nothing
End Sub