Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Workspace, CreateUser, and Append (Oh, my!) 1

Status
Not open for further replies.

KornGeek

Programmer
Joined
Aug 1, 2002
Messages
1,961
Location
US
I've been looking at a lot of code to allow me to programatically create users and add them to groups. While the code works, I don't completely understand it, and would like some clarification.

1) This may seem obvious to many of you, but just what are Workspaces? I seem them reference in code, but I'm not sure what they are or what you do with them.

2) The code below is a sample of some of the code I have found. It uses the command CreateUser, and then Append. What do each of these commands do? I have been unable to find answers in the Access help files or by searching online. This code is used to create a new user profile, and similar code is used to add a user to a group. (This code is borrowed from a post by JeremyNYC.)

Public Function CreateUser(ByVal sUserName As String) As Boolean
Dim ws As Workspace
Dim usr As User
Dim grpUsers As Group
Dim sSql As String
Dim sPID As String
Dim SPWD As String

Set ws = DBEngine.Workspaces(0)
.
.
.
Set usr = ws.CreateUser(sUserName, sPID, sPWD)
ws.Users.Append usr
.
.
.


I appreciate any insight you can give me into these commands. [morning] Sleep is for people with no caffeine.
 
These topics are available in the VBA Help file, not the Access Help file.

In A2K or A2K2, open any code module and click on the Help Menu, and then on "Visual Basic Help". Sorry, I can't remember if this works in A97 or not.

HTH
Lightning
 
My VBA help is not properly installed. When I try to view the help for Workspaces for instance, I get the error message "Microsoft Access can't display Help. An error occurred and this feature is no longer functioning properly. Would you like to repair this feature now?"

Whan I have tried to repair it, Access re-installs help, reboots my computer, and then I get the same error message.

I am using Access 2000, by the way. [morning] Sleep is for people with no caffeine.
 
From the VBA Help File

Workspaces Collection


A Workspaces collection contains all active, unhidden Workspace objects of the DBEngine object. (Hidden Workspace objects are not appended to the collection and referenced by the variable to which they are assigned.)

DBEngine
|
|--Workspaces
|
|--Workspace
|
|--Connections
|--Databases
|--Groups
|--users

Remarks
Use the Workspace object to manage the current session or to start an additional session.

When you first refer to or use a Workspace object, you automatically create the default workspace, DBEngine.Workspaces(0). The settings of the Name and UserName properties of the default workspace are "#Default Workspace#" and "Admin," respectively. If security is enabled, the UserName property setting is the name of the user who logged on.

You can create new Workspace objects with the CreateWorkspace method. After you create a new Workspace object, you must append it to the Workspaces collection if you need to refer to it from the Workspaces collection. You can, however, use a newly created Workspace object without appending it to the Workspaces collection.

To refer to a Workspace object in a collection by its ordinal number or by its Name property setting, use any of the following syntax forms:

DBEngine.Workspaces(0)

DBEngine.Workspaces("name")

DBEngine.Workspaces![name]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top