>

UserName Property

Applies To

Container Object, Document Object, Workspace Object.

Description

Sets or returns a value that represents a user or group of users or the owner of a Workspace object. For Container and Document objects, this property setting is read/write. For a Workspace object, this property setting is read/write for an object not yet appended to a collection and read-only for an existing Workspace object.

Settings and Return Values

The setting or return value is a string expression that evaluates to the name of a User object in the Users collection or a Group object in the Groups collection. (Data type is String.)

Remarks

Depending on the type of object, the UserName property represents:

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 sets the access permissions for a table named MyTable in the specified database for a user named Millicent to read-only. The code then checks to see if Millicent has permission to add records.


Dim wrkDefault As Workspace, dbsNorthwind As Database
Dim docMyTable As Document
...
Set wrkDefault = DBEngine.Workspaces(0)
Set dbsNorthwind = wrkDefault.OpenDatabase("Northwind.mdb")
...
Set docMyTable = dbsNorthwind.Containers("Tables")![MyTable]
docMyTable.UserName = "Millicent"
docMyTable.Permissions = dbSecRetrieveData
If(docMyTable.Permissions and dbSecInsertData) > 0 Then
    Debug.Print "Millicent can insert data."
Else
    Debug.Print "Millicent can't insert data."
End If
...
Example (Microsoft Access)

See the Permissions property example (Microsoft Access)