UserName Property

Applies To

Container object, Document object, Workspace object.

Description

Sets or returns a value that represents a user, a group of users, or the owner of a Workspace object.

Settings and Return Values

The setting or return value is a String that evaluates to the name of a user. In a Microsoft Jet workspace, this represents a User object in the Users collection or a Group object in the Groups collection. For Microsoft Jet Container and Document objects, this property setting is read/write. For all Workspace objects, this property setting is read-only.

Remarks

Depending on the type of object, the UserName property represents the following.

  • The owner of a Workspace object.
  • A user or group of users when you manipulate the access permissions of a Container object or a Document object (Microsoft Jet workspaces only).
To find or set the permissions for a particular user or group of users, first set the UserName property to the user or group name that you want to examine. Then check the Permissions property setting to determine what permissions that user or group of users has, or set the Permissions property to change the permissions.

For a Workspace object, check the UserName property setting to determine the owner of the Workspace object. Set the UserName property to establish the owner of the Workspace object before you append the object to the Workspaces collection.

See Also

Append method, Inherited property, Password property, Permissions property.

Example

This example uses the UserName property to change a particular user's permissions on an object and to verify that user's ability to append new data to the same object.

Sub UserNameX()

    ' Ensure that the Microsoft Jet workgroup information
    ' file is available.
    DBEngine.SystemDB = "system.mdw"

    Dim dbsNorthwind As Database
    Dim docTemp As Document

    Set dbsNorthwind = OpenDatabase("Northwind.mdb")

    Set docTemp = _
        dbsNorthwind.Containers("Tables").Documents(0)

    ' Change the permissions of NewUser on the first Document
    ' object in the Tables container.
    With docTemp
        .UserName = "NewUser"
        .Permissions = dbSecRetrieveData
        If (.Permissions And dbSecInsertData) = _
                dbSecInsertData Then
            Debug.Print .UserName & " can insert data."
        Else
            Debug.Print .UserName & " can't insert data."
        End If
    End With

    dbsNorthwind.Close

End Sub
Example (Microsoft Access)

See the Permissions property example (Microsoft Access).