Databases Reference
In-Depth Information
14.8.3 Workspaces
There is one Workspace object for each Access user session. In a single-user
environment, there is generally only one session running. When a user starts Access with
no security options enabled, Access automatically creates a Workspace called:
DBEngine.Workspaces(0)
Since we are not concerned in this topic with multiple users or with database-security
issues, we will not be creating multiple workspaces.
The values of the Name and UserName properties of the default Workspace object are
easily determined by running the following code:
Sub Test( )
MsgBox "Count: " & DBEngine.Workspaces.Count
MsgBox "Name: " & DBEngine.Workspaces(0).Name
MsgBox "UserName: " & DBEngine.Workspaces(0).UserName
End Sub
This code should produce three message boxes, indicating that there is only one open
workspace, with name #Default Workspace# and username admin .
Among the methods of a Workspace object are CreateDatabase (for creating a new
database) and OpenDatabase (for opening an existing database). Another interesting
group of methods is BeginTrans , CommitTrans , and Rollback , which allow the
programmer to group several operations into one transaction. At the end of the
transaction, the programmer can commit the operations—or rollback the database to its
state prior to any of the operations in the transaction. One use for this is in updating
related tables (as in transferring money from one table to another). If the entire group of
operations is not completed successfully, then a rollback is probably desirable.
Workspace objects also have a Close method for closing opened workspaces. However,
the method is ignored when applied to the default Workspace under Microsoft Access.
14.8.4 Users
The Jet engine provides security by assigning access permissions to users of the engine.
A User object represents a user of the Jet engine. The Users collection contains all User
objects. (Of course, female users are never to be considered objects.)
14.8.5 Groups
A Group object represents a set of User objects (users) that have a common set of access
permissions. By using Group objects, a new user can be given a set of access permissions
Search WWH ::




Custom Search