When was report printed?

J

Joy

Hi,
Is there a way to tell when a form was opened or a report was printed in an
Access 2000 database. The db has security levels on it and there is a user
log that stamps the user name, date and time every time someone opens the
database but not what they access from that point on.

Thanks,
Joy
 
J

Jeff Conrad

Is there a way to tell when a form was opened or a report was printed in an
Access 2000 database. The db has security levels on it and there is a user
log that stamps the user name, date and time every time someone opens the
database but not what they access from that point on.

Hi Joy,

There is nothing built into Access that will do this, but it is quite easy to
create a recording method. I remember a post from MVP Albert Kallal
a couple of years ago where he detailed that he logs which forms, reports,
etc are opened as well as what toolbar/menu bar options are used. He uses
this information to see what options are used the most (or over used), and
which options are used the least. He can then make improvements to the
program. I can provide a link to that post if you would like.

Anyway, here is a little something I just put together. You can increase or
decrease the complexity as much as you desire. This will record who opens
what form or report. Follow these steps.

1. Create a new table called tblActivityLog with the following fields:
fldObjectLogID - AutoNumber
fldObjectName - Text
fldTimeOpened - Date/Time
fldUser - Text

2. Create a new standard module and copy/paste this code into it:

Public Sub subLogActivity(strObjectName As String)
On Error GoTo ErrorPoint

' Jeff Conrad - Access Junkie
' 1/28/05
' You are free to use this code in any projects
' so long as you admit you are an Access Junkie

Dim dbs As DAO.Database
Dim rst As DAO.Recordset

Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("tblActivityLog", , dbAppendOnly)

With rst
.AddNew
!fldObjectName = strObjectName
!fldTimeOpened = Now()
!fldUser = CurrentUser()
.Update
End With

ExitPoint:
On Error Resume Next
' Cleanup Code
rst.Close
Set rst = Nothing
Set dbs = Nothing
Exit Sub

ErrorPoint:
' Unexpected Error
MsgBox "The following error has occurred:" _
& vbNewLine & "Error Number: " & Err.Number _
& vbNewLine & "Error Description: " & Err.Description _
, vbExclamation, "Unexpected Error"
Resume ExitPoint

End Sub

3. Make sure you have a reference set to the DAO object library.

4. Compile the code, and save the module as basLogActivity.

5. Now put the following one line of code in EVERY form and report's
Open event that you want to track:

Call subLogActivity(Me.Name)

You will now see that whenever the form or report opens it will make a
record in the table and show what was opened, by whom, and when.
You can then make some nice queries and reports off this table information.
For example, you could do a query by a user and see everything they
have done. You could also query a specific database object and see
who opened it.

Hope that gets you going,
 
J

Jeff Conrad

Jeff,
Thanks for your help. This code is absolutely great and is exactly what I'm
looking for. I can also it to see what reports are used less frequently or at all.

Excellent, glad the code was what you were looking for.
I would also appreciate the link you mentioned from Albert Kallal MVP. I
did a search and found the following:
http://www.members.shaw.ca/AlbertKallal/msaccess/msaccess.html
Is this it?

That is Albert's web site yes, but the particular thread I was talking about
was this one on Google. Start from the top and work your way down.

http://tinyurl.com/3nyzo
Thanks again.

You're very welcome, glad I could help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top