INF: Sample Function to Return Users in Current System
  
PSS ID Number: Q109722
Article last modified on 10-04-1994
 
1.00 1.10
 
WINDOWS
 

---------------------------------------------------------------------
The information in this article applies to:
 
 - Microsoft Access versions 1.0 and 1.1
---------------------------------------------------------------------
 
SUMMARY
=======
 
This article describes a sample Access Basic function to use to return a
list of users in the current Microsoft Access system.
 
Notes
-----
 
 - The technique described below relies on the use of system tables
   stored with your database. These tables are undocumented and are
   subject to change in future versions of Microsoft Access.
 
 - This article assumes that you are familiar with Access Basic and with
   creating Microsoft Access applications using the programming tools
   provided with Microsoft Access. For more information on Access Basic,
   please refer to the "Introduction to Programming" manual.
 
MORE INFORMATION
================
 
The following function returns a comma-separated list of users in the
current Microsoft Access system database. The function takes one argument
that specifies the complete path and filename for the SYSTEM.MDA file you
want to query.
 
NOTE: In the following sample code, an underscore (_) is used as a line-
continuation character. Remove the underscore when re- creating this code
in Access Basic.
 
   Function CurrentUsers (SysDB As String)
      Dim DB As Database
      Dim DS As Dynaset
      Dim CurrUser As String, Users As String
      Dim Counter As Integer
 
      On Error GoTo FileError
 
      Set DB = OpenDatabase(SysDB)
      Set DS = DB.CreateDynaset("MSysUserList")
 
      DS.MoveLast
      DS.MoveFirst
 
      For Counter = 1 To DS.RecordCount
         Users = Users & IIf(Len(Users) > 0, ",", "") & DS![Name]
         DS.MoveNext
      Next Counter
 
      DS.Close
      DB.Close
 
      CurrentUsers = Users
 
      Exit Function
 
   FileError:
      MsgBox "The Following Error Occurred:" & Chr$(13) & Chr$(10) &_
      Chr$(13) & Chr$(10) & Error$
      Exit Function
 
   End Function
 
To run this function on a system where the SYSTEM.MDA file is located in
the ACCESS directory on the C drive, type the following in the module's
Immediate window, and then press ENTER:
 
   ? CurrentUsers("C:\ACCESS\SYSTEM.MDA")
 
If the Microsoft Access system has no users added to it, you will receive
the following list:
 
   admin,Creator,Engine,guest
 
REFERENCES
==========
 
Microsoft Access "Language Reference," versions 1.0 and 1.1, pages 88-90,
198-199, 311-312, and 390-391
 
Additional reference words: 1.00 1.10 security
KBCategory: kbusage
KBSubcategory: ScrtOthr
=============================================================================
Copyright Microsoft Corporation 1994.
