Container Property
Applies To
Document object.
Description
Returns the name of the Container object to which a Document object belongs (Microsoft Jet workspaces only).
Return Values
The return value is a String data type.
See Also
Container object.
Example
This example displays the Container property for a variety of Document objects.
Sub ContainerPropertyX()
Dim dbsNorthwind As Database
Dim ctrLoop As Container
Set dbsNorthwind = OpenDatabase("Northwind.mdb")
' Display the container name for the first Document
' object in each Container object's Documents collection.
For Each ctrLoop In dbsNorthwind.Containers
Debug.Print "Document: " & ctrLoop.Documents(0).Name
Debug.Print " Container = " & _
ctrLoop.Documents(0).Container
Next ctrLoop
dbsNorthwind.Close
End Sub
Example (Microsoft Access)
The following example determines the name of the Container object to which a Document object belongs, and sets permissions accordingly for the specified group account. Remember that you must denote a particular user or group account before you set permissions for an object. The following example assumes that you have defined a Marketers group.
Microsoft Access defines additional Container objects beyond those defined by the Microsoft Jet database engine. These include the Form, Report, Script, and Module Container objects.
Note that the Or operator performs a bitwise comparison to determine whether an attribute is currently set.
Sub SetDocPermissions(docUnknown As Document)
Dim strContainerName As String
' Set UserName property to valid existing group account.
docUnknown.UserName = "Marketers"
' Get value of Container property.
strContainerName = docUnknown.Container.Name
Select Case strContainerName
Case "Forms"
' Set permissions for Form Document object.
docUnknown.Permissions = docUnknown.Permissions Or _
acSecFrmRptWriteDef
Case "Reports"
' Set permissions for Report Document object.
docUnknown.Permissions = docUnknown.Permissions Or _
acSecFrmRptExecute
Case "Scripts"
' Set permissions for Script Document object.
docUnknown.Permissions = docUnknown.Permissions Or _
acSecMacWriteDef
Case "Modules"
' Set permissions for Module Document object.
docUnknown.Permissions = docUnknown.Permissions Or _
acSecModReadDef
Case Else
Exit Sub
End Select
End Sub