| re: Set the max number of users
I'm not sure about the tblSysConstants, as I've never used it. But I'll
include a function I use in Access 97 that works, so hopefully it will work
in 03 as well. Basically, when a user is connected to an .mdb file, an .ldb
file is created. I looked into this file and found that it should contain
the name of the machines logged in. So I wrote a function that will count
the names in the .ldb file. Just pass the database name to it, such as
database.mdb, and it will look in database.ldb:
--------------------
Public Function NumUsers(DBName As String) As Integer
On Error GoTo ErrRtn
Dim UserName As String, UserRight As String, UserList As String
Dim ldbName As String
ldbName = Left(DBName, Len(DBName) - 4)
ldbName = Trim(ldbName & ".ldb")
NumUsers = 0
Open ldbName For Input Shared As #1
Do While Not EOF(1)
UserName = Input(31, #1)
NumUsers = NumUsers + 1
UserRight = Input(5, #1)
'if char = asc(32)
'Debug.Print Trim$(UserName)
UserList = UserList & Trim$(UserName) & ";"
Loop
'Debug.Print Chr(10) & Chr(13)
'Debug.Print "Number of users is: " & NumUsers
'Forms!fLoggedIn.lstUsers.RowSource = UserList
'Forms!fLoggedIn.Form!lblMsg.Caption = "Number Logged In: " & NumUsers
Close #1
'now find the number of users logged in through all add-ins and deduct them
from the total
Exit Function
ErrRtn:
NumUsers = 1
If err = 53 Then '.ldb file not found
'MsgBox "There are no user's in this .ldb file"
'Forms!fLoggedIn.Form!lstUsers.RowSource = ""
'Forms!fLoggedIn.Form!lstUsers.Requery
'Forms!fLoggedIn.Form!lblMsg.Caption = "Number Logged In: 0"
ElseIf err = 62 Then
Close #1
Exit Function
Else
MsgBox err.Number & " - " & err.Description & ", Function: NumUsers"
End If
End Function |