Option Compare Database
Option Explicit
Private mastrUsers() As String
Private mintTotalUsers As Integer
Function
acbFillUserList(ctl As Control, varID As Variant, _
varRow As Variant, varCol As Variant, varCode As Variant) _
As Variant
' List filling function for users.
Dim varRetVal As Variant
varRetVal = Null
Select Case varCode
Case acLBInitialize
mintTotalUsers = GetUserArray()
varRetVal = True
Case acLBOpen
varRetVal = Timer
Case acLBGetRowCount
varRetVal = mintTotalUsers
Case acLBGetValue
varRetVal = mastrUsers(varRow)
End Select
acbFillUserList = varRetVal
End Function
Private Function GetUserArray() As Integer
' Fills mmastrUsers() with a list
' of user account names.
' Returns the total number of accounts.
Dim intI As Integer
Dim intUser As Integer
Dim intTotalUser As Integer
Dim wrk As Workspace
Dim strUser As String
' There are two "special" (for internal use) accounts
' which you can't actually use (Engine and Creator),
' so we've eliminated them from consideration
Const acbcNumSpecialAccnts = 2
Set wrk = DBEngine.Workspaces(0)
wrk.Users.Refresh
' Total count of users including
' the two special accounts
intTotalUser = wrk.Users.Count
' Don't include the special accounts
' when dimensioning the array
ReDim mastrUsers(intTotalUser - acbcNumSpecialAccnts)
intUser = 0
' Interate through all accounts,
' adding an account if it is not
' one of the special accounts
For intI = 0 To intTotalUser - 1
strUser = wrk.Users(intI).Name
' You might wish to also eliminate the built-in "Admin"
' account. If so, add it to the following If...Then
' expression and bump up acbcNumSpecialAccnts to 3.
If strUser <> "Engine" And strUser <> "Creator" Then
mastrUsers(intUser) = strUser
intUser = intUser + 1
End If
Next intI
' Return the total number of non-special accounts
GetUserArray = intTotalUser - acbcNumSpecialAccnts
End Function