Current Users

cable

Access For My Sins
Local time
Today, 11:25
Joined
Mar 11, 2002
Messages
226
Just wondering what people use to see who's in the a database?

We have a few systems where we need to know who's in and its proving difficult. ldb only shows the computer name, and thats not good enough (we can't use net send to tell em "to get orff":D)
One of the ones I inherited uses a table to store the names, thats getting there but can be unreliable, and hard to use when there is different programs accessing the same backend.

Is there a system utility that will do it? I'm sure it must be possible because windows wont allow you to delete a file in use!

Or is there a network utility that can match the network computer name to the currently logged in user?
 
I've almost finished a little sample database that will let you monitor people in a range of databases - a few more days. ;)
 
In side the .ldb, unless you invoke a sercurity schema, that's all you'll get. When you do security, you should see the current user. You may be able to do a API call, 'CurrentUser()', on a network machine...
 
I've knocked up a very simple current user system, it aint nowt special but does it's job:
Code:
Public Sub InDB()
'adds user to text file
Dim sLines() As String, sLine As String, sFileName As String
Dim iFNo As Integer, iC As Integer
Dim bIn As Boolean

sFileName = CurrentDb.Name
sFileName = sFileName & ".users"
bIn = False

If Exists(sFileName) = True Then
    iFNo = FreeFile
    Open sFileName For Input As #iFNo
    iC = 0
    Do Until EOF(iFNo)
        ReDim Preserve sLines(0 To iC + 1)
        Input #iFNo, sLine
        If IsNull(sLine) = False And sLine <> "" Then
            sLines(iC) = sLine
            If sLine = FileString Then bIn = True
            iC = iC + 1
        End If
    Loop
    Close #iFNo
End If

If bIn = False Then
    'add user
    iFNo = FreeFile
    Open sFileName For Append As #iFNo
    Print #iFNo, FileString
    Close #iFNo
End If
msgbox "done"
End Sub

Public Sub OutDB()
'removes user from text file
Dim sLines() As String, sLine As String, sFileName As String
Dim iFNo As Integer, iC As Integer
Dim bIn As Boolean

sFileName = CurrentDb.Name
sFileName = sFileName & ".users"
bIn = False

If Exists(sFileName) = True Then
    iFNo = FreeFile
    Open sFileName For Input As #iFNo
    iC = 0
    Do Until EOF(iFNo)
        ReDim Preserve sLines(0 To iC + 1)
        Input #iFNo, sLine
        If IsNull(sLine) = False And sLine <> "" Then
            sLines(iC) = sLine
            If sLine = FileString Then bIn = True
            iC = iC + 1
        End If
    Loop
    Close #iFNo
End If

'rewrite entire file
If bIn = True Then
    Kill sFileName
    iFNo = FreeFile
    Open sFileName For Append As #iFNo
    For iC = 0 To UBound(sLines)
        If sLines(iC) <> FileString Then Print #iFNo, sLines(iC)
    Next iC
    Close #iFNo
End If
End Sub

Private Function FileString() As String
FileString = OSUserName & "-" & OSMachineName
End Function
OSUserName and OSMachineName are simple api calls returning the windows current user and network machine name, and exists is file existance checking function:).
 
cable -

Thanks for posting a great solution to a need that I've had for a while now.

Thought you might enjoy this...
I've added some code from Mile-O-Phile's related solution that I also just discovered.

This produces a FileString value such as...
UserName: susan --- ComputerName: KATHERINA --- ScreenResolution: 800x600 --- AccessVer: 9.0 --- AccessDir: C:\Program Files\Microsoft Office\Office\ --- IsRuntime: No --- OperatingSystem: Windows 2000 --- OSMajorVersion: 5 --- OSMinorVersion: 0 --- OSServicePack: Service Pack 3 --- TimeOffsetFromUMT: 480 minute(s) --- WindowsStarted: 7/13/2004 12:27:01 PM

Mile-O-Phile's posting...
http://www.access-programmers.co.uk/forums/showthread.php?s=&threadid=59501
(Remember to add the two modules Mile-O-Phile's the attachment.)

Private Function FileString() As String
On Error GoTo Exit_Form_Load

Dim CComp As New CComputer

With CComp
FileString = "UserName: " & .UserName
FileString = FileString & " --- ComputerName: " & .ComputerName
FileString = FileString & " --- ScreenResolution: " & .ScreenResolution
FileString = FileString & " --- AccessVer: " & .AccessVer
FileString = FileString & " --- AccessDir: " & .AccessDir
FileString = FileString & " --- IsRuntime: " & IIf(.IsRuntime, "Yes", "No")
FileString = FileString & " --- OperatingSystem: " & .OperatingSystem
FileString = FileString & " --- OSMajorVersion: " & .OSMajorVersion
FileString = FileString & " --- OSMinorVersion: " & .OSMinorVersion
FileString = FileString & " --- OSServicePack: " & .OSServicePack
FileString = FileString & " --- TimeOffsetFromUMT: " & .TimeOffset & " minute(s)"
FileString = FileString & " --- WindowsStarted: " & DateAdd("s", -(.WinStarted / 1000), Now())
End With

Exit_Form_Load:
Set CComp = Nothing

End Function
 
Last edited:

Users who are viewing this thread

Back
Top Bottom