Programmatically Track Users and Groups
Problem
As the database administrator, you want to be able to track users and their groups within your workgroup. You know you can use Tools → Security → Print Security to print a report of users and groups, but you’d like to be able to use that information as part of the applications you write. How can you gather the information you need?
Solution
Using Data Access Objects (DAO), you can retrieve all the information you need about users’ names and groups. Once you have that information, you can use it in creating your applications.
The sample form frmUserGroups in 10-05.MDB
fills
tables with the information you need and presents it to you in a list
box. To test it, open and run frmUserGroups. Figure 10-20 shows the form in use for a sample workgroup.
Figure 10-20. frmUserGroups shows users and groups for a sample workgroup
To gather this information in your own applications, follow these steps:
Create the tables you’ll need to hold the information. Either import the three tables from
10-05.MDB
, or use the information in Table 10-13 to create your own.Table 10-13. Table layouts for gathering user/group information
Table name
Field name
Field type
Primary key?
tblGroups
Group
Text
No
GroupID
Counter
Yes
tblUserGroups
UserID
Number (Long Integer)
Yes
GroupID
Number (Long Integer)
Yes
tblUsers
UserName
Text
No
UserID ...
Get Access Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.