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.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).