Article ID: 210154 - View products that this article applies to.
This article was previously published under Q210154
This article has been archived. It is offered "as is" and will no longer be updated.
This article describes a method that you can use to transfer the ownership of a newly created table to a specific owner. For example, if the functionality within a secured database enables the current user to import a table, that user will be the owner of the table and will have full permissions on that table.
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
If your secured database application enables users to import a table, those users will be the owners of the table and will have full permissions on that table. The function in this article demonstrates how you can programmatically create a secured session as a user different from the current user and transfer ownership of an imported object from the current user to another user.
Call the following function within a macro, a function, or a Sub procedure that imports the table that you want to secure. Call the function immediately after importing the table to ensure that permissions have been set.
To use the ChangeOwner function, use either of the following methods. Each assumes 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")
For more information about database security and object ownership, click Microsoft Access Help on the Help menu, type secure a microsoft access database in the Office Assistant or the Answer Wizard, and then click Search to view the topics returned.
For more information about running a Function procedure from a macro, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type runcode action in the Office Assistant or the Answer Wizard, and then click Search to view the topic.