>
Dim dbsNorthwind As Database, conTables As Container Set dbsNorthwind = DBEngine.Workspaces(0).OpenDatabase("Northwind.mdb") Set conTables = dbsNorthwind.Containers("Tables") conTables.Inherit = True conTables.Permissions = dbSecWriteSec dbsNorthwind.CloseExample (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.
Sub FormPermissions() Dim dbs As Database, ctrForms As Container Dim docForm As Document, frmNew As Form ' Return Database variable that points to current database. Set dbs = CurrentDb ' Return Container variable pointing to Forms Container object. 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 End Sub