Yes it is.
First create a table with these fields; Call it LogInTable
UserName
LogInDate
LogInTime
LogOutTime
Then copy this code and paste it into a new module exactly as it is.
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String, db As Database, r As Recordset, rst As Recordset
Dim table2 As String
Set db = CurrentDb
Set r = db.OpenRecordset("LogInTable")
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If lngX <> 0 Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = ""
End If
r.MoveLast
r.AddNew
r.Fields("UserName") = UCase(fOSUserName)
r.Fields("LogInDate") = Date
r.Fields("LogInTime") = Time
r.Update
End Function
Then OnLoad of the switchboard - Call FosUserName()
The data will then be posted to the table when the user logs in.
OnClose of the switchboard run an UpDate query to add the logout time.
If you do a Me.refresh on the timer of the switchboard - say every 30 seconds, you'll pick up new users who have logged on.
Col
