>

Permissions Property

Applies To

Container Object, Document Object.

Description

Sets or returns a value that establishes the permissions for the user or group identified by the UserName property of the Container or Document object.

Settings and Return Values

The setting or return value is a constant that establishes permissions. Possible settings or return values are:

Constant

Description

dbSecNoAccess

No access to the object.

dbSecFullAccess

Full access to the object.

dbSecDelete

Can delete the object.


Constant

Description

dbSecReadSec

Can read the object's security-related information.

dbSecWriteSec

Can alter access permissions.

dbSecWriteOwner

Can change the Owner property setting.


For the Tables Container object or any Document object in a Documents collection, the possible settings or return values are:

Constant

Description

dbSecCreate

Can create new documents (valid only with a Container object).

dbSecReadDef

Can read the table definition including column and index information.

dbSecWriteDef

Can modify or delete the table definition including column and index information.

dbSecRetrieveData

Can retrieve data from the Document object.

dbSecInsertData

Can add records.

dbSecReplaceData

Can modify records.

dbSecDeleteData

Can delete records.


For the Databases Container object or any Document object in a Documents collection, the possible settings or return values are:

Constant

User or group

dbSecDBAdmin

Gives user permission to make a database replicable and change the database password.

dbSecDBCreate

Can create new databases (valid only on the databases Container object in the system database [Systen.mdw]).

dbSecDBExclusive

Exclusive access.

dbSecDBOpen

Can open the database.


Remarks

These constants are listed in the Data Access (DAO) object library in the Object Browser.

Use this property to establish or determine the type of read/write/modify permissions the user has for a Container or Document object.

A Document object inherits the permissions for users from its Container object, provided the Inherited property of the Container object is set for those users or for a group to which the users belong. By setting a Document object's Permissions and UserName properties later, you can further refine the access control behavior of your object.

See Also

Inherited Property, UserName Property.

Specifics (Microsoft Access)

Microsoft Access defines four types of Container objects in addition to those defined by the Microsoft Jet database engine. These include the Forms, Reports, Scripts, or Modules Container objects. Individual Form, Report, Script and Module Document objects belong to the Documents collections of these Container objects. For these Container and Document objects, you can also set the Permissions property to the following constants.

Constant

User or group can

acSecFrmRptReadDef

Open the form or report in Design view but not make any changes.

acSecFrmRptWriteDef

Modify or delete the form or report in Design view.

acSecFrmRptExecute

Open the form in Form view or Datasheet view; print or open the report in Sample Preview or Print Preview.

acSecMacReadDef

Open the Macro window and view a macro without making changes.

acSecMacWriteDef

Modify or delete the macro in the Macro window.

acSecModReadDef

Open the module but not make any changes.

acSecModWriteDef

Modify or delete the contents of a module.

acSecMacExecute

Run the macro.


Example

This example prints the Permissions property setting of a Document object for the current user.


Dim dbsNorthwind As Database, docTest As Document
Set dbsNorthwind =  DBEngine.Workspaces(0).OpenDatabase("Northwind.mdb")
Set docTest = dbsNorthwind.Containers(0).Documents("MyDoc")
Debug.Print docTest.Permissions
Example (Microsoft Access)

The following example adds a new user account by creating a User object and appending it to the Users collection of the default workspace. It then sets permissions for the new user for all tables in the database. The procedure first sets the UserName property of a Tables Container object to the name of the new user, then sets the Permissions property to the appropriate permissions. Note that the security constants used to set the Permissions property are Integer values, so the + (plus sign) operator is used to add them.


Sub SetPermissions()
    Dim dbs As Database, ctrTables As Container
    Dim wspDefault As Workspace, usrNew As User
    
    ' Return Workspace object pointing to default workspace.
    Set wspDefault = DBEngine.Workspaces(0)
    ' Create User object, specifying Name, PID, and Password.


    Set usrNew = wspDefault.CreateUser("Kevin Smith", "ABC123XYZ123",_
"Password") ' Append to Users collection of default workspace. wspDefault.Users.Append usrNew ' Return Database variable pointing to current database. Set dbs = CurrentDb ' Return Container variable pointing to Tables Container object. Set ctrTables = dbs.Containers!Tables ctrTables.UserName = usrNew.Name ' Set new user's permissions for tables. ctrTables.Permissions = dbSecInsertData + dbSecReplaceData + _
dbSecDeleteData End Sub