J
John Bigness
I support a shared Access database and have the following code to record in
tbl_SignOn when somebody opens the program.
Function AddtoSignOnHistory()
On Error GoTo Err_AddtoSignonHistory
Dim strUser As String
Dim mydbase As Database
Dim rs As Recordset
Set mydbase = CurrentDb
Set rs = mydbase.OpenRecordset("tbl_SignOn")
strUser = Environ$("username")
rs.AddNew
rs![User] = strUser
rs![LogDate] = Date
rs![LogTime] = Time
rs.Update
rs.Close
Exit_AddtoSignonHistory:
Exit Function
Err_AddtoSignonHistory:
MsgBox Err.Description
Resume Exit_AddtoSignonHistory
End Function
The structure of the tbl_SignOn is:
ID Autonumber
UserName Text
Login Date Date/Time
Login Time Date/Time
I would like to add 2 fields - Logoff Date and Logoff Time so that I then
run a query showing who is currently signed on (LoginDate is not null and
LogOffDate is Null).
Question:
Is there an event which could be used which would run some code to record
the Log Off Date and Log Off time when somebody logs off (closes) the
database or do I have to rely on an Exit button off the Main Menu?
tbl_SignOn when somebody opens the program.
Function AddtoSignOnHistory()
On Error GoTo Err_AddtoSignonHistory
Dim strUser As String
Dim mydbase As Database
Dim rs As Recordset
Set mydbase = CurrentDb
Set rs = mydbase.OpenRecordset("tbl_SignOn")
strUser = Environ$("username")
rs.AddNew
rs![User] = strUser
rs![LogDate] = Date
rs![LogTime] = Time
rs.Update
rs.Close
Exit_AddtoSignonHistory:
Exit Function
Err_AddtoSignonHistory:
MsgBox Err.Description
Resume Exit_AddtoSignonHistory
End Function
The structure of the tbl_SignOn is:
ID Autonumber
UserName Text
Login Date Date/Time
Login Time Date/Time
I would like to add 2 fields - Logoff Date and Logoff Time so that I then
run a query showing who is currently signed on (LoginDate is not null and
LogOffDate is Null).
Question:
Is there an event which could be used which would run some code to record
the Log Off Date and Log Off time when somebody logs off (closes) the
database or do I have to rely on an Exit button off the Main Menu?