ACC2000: How to Add a User to a Group with CreateUser MethodID: Q210418
|
To add a user to an existing group with code, you must use the CreateUser method twice: once to create the new user for that Microsoft Access session, and again to create the user for the group.
Microsoft provides programming examples for illustration only, without warranty
either expressed or implied, including, but not limited to, the implied warranties of
merchantability and/or fitness for a particular purpose. This article assumes that you
are familiar with the programming language being demonstrated and the tools used to
create and debug procedures. Microsoft support professionals 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 needs. If you have limited
programming experience, you may want to contact a Microsoft Certified Solution Provider
or the Microsoft fee-based consulting line at (800) 936-5200. For more information about
Microsoft Certified Solution Providers, please see the following page on the World Wide Web:
http://www.microsoft.com/mcsp/For more information about the support options available from Microsoft, please see the following page on the World Wide Web:
http://www.microsoft.com/support/supportnet/overview/overview.asp
The following sample function called CUser() demonstrates how to create a user named MyName for the Users group:
Function CUser (uname As String, upin As String, upwd As String, _
gname As String)
Dim u As User, w As WorkSpace, g As Group
Set w = dbengine.workspaces(0) 'The default workspace.
Set u = w.CreateUser(uname, upin, upwd) 'Create a user for the
'Access session.
w.users.Append u 'Add user to workspace.
w.users.Refresh
Set g = w.groups(gname)
Set u = g.CreateUser(uname) 'Create a user for a
group.
g.users.Append u 'Add new user to group.
g.users.Refresh
End Function
? CUser ("MyName","1234","MyName","Users")
For more information about the CreateUser method, in the Visual Basic Editor, click
Microsoft Visual Basic Help on the Help menu, type "CreateUser" in
the Office Assistant or the Answer Wizard, and then click Search to
view the topic.
Additional query words: inf
Keywords : kbprg kbdta PgmObj ScrtUsr
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: July 6, 1999