Inherit Property

Applies To

Container object.

Description

Sets or returns a value that indicates whether new Document objects will inherit a default Permissions property setting (Microsoft Jet workspaces only).

Settings and Return Values

The setting or return value is a Boolean data type. If you set the property to True, Document objects inherit a default Permissions property setting.

Remarks

Use the Inherit property in conjunction with the Permissions property to define what permissions new documents will automatically have when they're created. If you set the Inherit property to True, and then set a permission on a container, then whenever a new document is created in that container, that permission will be set on the new document. This is a very convenient way of presetting permissions on an object.

Setting the Inherit property will not affect existing documents in the container — you can't modify all the permissions on all existing documents in a container by setting the Inherit property and a new permission. It will affect only new documents that are created after the Inherit property is set.

See Also

Document object, Permissions property.

Example

This example sets the Tables container's Inherit property to True so that any subsequently created Document objects in the Tables container will have the same security settings as the Tables container.

Sub InheritX()

    Dim dbsNorthwind As Database
    Dim conTables As Container

    Set dbsNorthwind = OpenDatabase("Northwind.mdb")
    Set conTables = dbsNorthwind.Containers("Tables")

    ' By setting the Inherit property of the Tables container
    ' to true and setting its permissions, any new Document
    ' object in this container will inherit the same
    ' permissions setting.
    conTables.Inherit = True
    conTables.Permissions = dbSecWriteSec

    dbsNorthwind.Close

End Sub
Example (Microsoft Access)

The following example sets the Inherit property of the Forms Container object to True (–1), and then sets the Permissions property to give users full security access to all forms. All new Document objects of the Form type will inherit these permissions. The procedure then creates a new Form object and displays the permissions for that object.

Note that the Forms Container object is different from the Forms collection. The Forms Container object includes all Form Document objects in the database; the Forms collection contains only currently open forms.

Also note that the Or operator performs a bitwise comparison to determine what permissions are currently set.

Sub FormPermissions()
    Dim dbs As Database, ctrForms As Container
    Dim docForm As Document, frmNew As Form

    ' Return reference to current database.
    Set dbs = CurrentDb
    ' Return reference to Forms container.
    Set ctrForms = dbs.Containers!Forms
    ' Set Inherit property.
    ctrForms.Inherit = True
    ' Set permissions to be inherited.
    ctrForms.Permissions = ctrForms.Permissions Or acSecFrmRptWriteDef
    ' Create new form.
    Set frmNew = CreateForm()
    ' Save form.
    DoCmd.Save , "OrderForm"
    ' Return Document object associated with new form.
    Set docForm = ctrForms.Documents!OrderForm
    ' Compare permissions for Container and Document objects.
    If docForm.Permissions <> ctrForms.Permissions Then
        MsgBox "Error!"
    Else
        MsgBox "Permissions successfully inherited."
    End If
    Set dbs = Nothing
End Sub