on load of the main menu, log the person in...
Code:
Private Sub Form_Load()
Post2Log "Login","db","user login"
end sub
There isn't an application quit or close event for MS Access. The common approach seems to be having a hidden form open at all times and then handling any logic for the application within the unload event for that form (which will always be fired before Access completely closes).
Post2Log "Exit","db","user quit"
Code:
'------------
Public Sub Post2Log(pvEvent, pvSubEvent, pvDescr)
'------------
const Q = """"
vUser = Environ("Username")
sSql = "INSERT INTO tLogs ([Event],[subEvent],[USER],[EntryDate]) " _
values (" & Q & pvEvent & Q & ",'" & pvSubEvent & "','" & vUser & "',#" & Now() & "#")"
docmd.setwarnings false
docmd.runSql sSql
docmd.setwarnings true
end sub