Article ID: 141887
Article Last Modified on 1/19/2007
Function ChangeOwner(NewTable As String, NewOwner As String, PWord As _
String)
Dim NewWS As WorkSpace
Dim db As Database
Dim cnt As Container
Dim doc As Document
Set db = CurrentDB()
'Create a new session and append it to the Workspaces collection.
Set NewWS = dbengine.CreateWorkspace("NewWS", NewOwner, PWord)
'Assign variables for the table's Container and Document objects.
Set cnt = db.Containers("Tables")
Set doc = cnt.Documents(NewTable)
'Establish new owner of the imported table.
doc.Owner = NewOwner
'Cleanup.
NewWS.Close
db.Close
'Pass success status back to caller.
ChangeOwner = True
End Function
To use this function, use either of the following methods. Each
presumes that the table has just been imported, that the table is named
MyTable, and that a valid user named MyNewOwner with a password of
MyNewOwnerPass exists.
Action: RunCode
Function Name: ChangeOwner("MyTable","MyNewOwner", "MyNewOwnerPass")
Dim IsOwnerChanged as Integer
IsOwnerChanged = ChangeOwner("MyTable", _"MyNewOwner", "MyNewOwnerPass")
Keywords: kbhowto kbprogramming kbusage KB141887