I am not sure how the code is applied. I have a setup screen cal
frmStartupScreen. How ddo I apply the code.
Does this code track the log out time entry.
Last, Can you get the User's full name from the network login.
Thank Your
:
Here is what I use.
I have a table called sysUsageLog consisting of 5 fields: CurrentTime
(PK),
UserName, Action, CurrentApp, Comment
Usage - During startup: Call UsageLogEntry("Log In", "optional comment
here")
The fOSUserName function (giving you the user's network ID) can be
found
at
http://www.mvps.org/access/api/api0008.htm
One advantage to this approach is that you can easily log any number
of
User
actions: changing a path setting, supplying a password, etc.
Another is that if you run into corruption problems, you may get some
clues
by talking to users who appear to log in but not out. In one case I
traced
a problem back to a user who was occasionally using TaskManager to
kill
their Access session because it seemed to hang. I found out what he
was
doing before it "hung up" and discovered that under certain
circumstances
I
had a very nasty piece of recursive code. If I had waited to store
LogIn
info until LogOut occurred I would never have had any reason to
specifically
ask this user about any problems he had experienced and the problem
would
have been recurring, long-standing and very annoying. In this case
the
"corruption" was fixed with a compact & repair of the backend, and the
"cause" of the apparent hang-up was recoded in 10 minutes.
******************************************
Public Sub UsageLogEntry(strAction As String, Optional varComment As
String)
' Adds an entry to table sysUsageLog upon specific events:
' Called from Database Startup (LogIn)
' PreExitRestore (LogOut)
' SupplyPassword (DataMaint)
On Error GoTo ErrHandler
Dim iAttempt As Integer
Dim dtmTime As Date
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("sysUsageLog")
iAttempt = 0
dtmTime = Now()
With rs
.AddNew
![UserName] = fOSUserName
![CurrentTime] = dtmTime
![CurrentApp] = Left$(db.Name, 100)
![Action] = strAction
If Len(varComment) = 0 Then
![Comment] = CStr(varComment)
End If
.Update
End With
rs.Close
ExitHere:
Set rs = Nothing
Set db = Nothing
Exit Sub
ErrHandler:
If rs Is Nothing Then
Resume ExitHere
End If
If iAttempt < 3 Then
iAttempt = iAttempt + 1
' Error may be caused by a duplicate DateTime stamp
(PrimaryKey)
Wait (1)
dtmTime = Now()
rs!CurrentTime = dtmTime
Resume
Else
Call ErrorLog(mDocName & ".UsageLogEntry")
Resume ExitHere
End If
End Sub
************************
HTH,
--
George Nicholson
Remove 'Junk' from return address.
I need to tracking log in and log out time of users.
My approach is to set up Public variable that store the [UserId],
[LogDate],[LogInTime] at the time of intial log in.
Add store the [LogOutTime] info at logoff time
How can I append this info to another table call "tblLogInTracking".
Do I use reecordsets and how?
Also will setup Public variables for user info conflict is a
multiuser
application.