Results 1 to 3 of 3

Thread: Activity Log

  1. #1
    2 Star Lounger
    Join Date
    May 2002
    Location
    Jerusalem, Israel
    Posts
    187
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi, All.

    I found instructions regarding creating an activity log. The instructions are located here.

    First create a simple table as described below:

    1] Create a table to hold the user log information and name it USysLog.
    Add these fields

    Event as Text
    EvTime as date/time

    Save the table and name it USysLog and click No when asked to create a Key field

    2] Create a module and add the following code. You can just cut and paste the following lines into a new module and save it using any name like LogMod.

    'cut here
    'Dimension a public variable at the top of the module.
    Public LogEvent As String

    'Next add this code in the module
    Public LogEvent As String

    Public Function LogEvt()
    Dim SQL As String
    SQL = "INSERT INTO UsysLog ( Event, EvTime ) SELECT '" & LogEvent & "' AS x1, #" & Now() & "# as x2;"
    DoCmd.RunSQL SQL
    End Function
    'cut here

    Close the module and save it as LogMod. (Name not important)

    3] Next add these two lines of code to each event that you want to record a time for and edit the first line for the appropriate form name and event. In this example, you would see the text "Logon Opened" and an associated time in the UsysLog table.

    LogEvent = " Status Change "
    LogEvt

    If you want to log a form opened time then put these lines in the "Form_Open" event and likewise if you want to log the form close time put it in the "Form_Closed" event and edit the wording on the first line accordingly. This way you will have a time stamp of the event in the UsysLog table with your own wording.
    I followed the instructions carefully, but they don't seem to work for me. I keep getting the error: Compile Error Sub or Function Not Defined.

    I put the following code in the "After Update" event of a dropdown list:

    LogEvent = " Logon Opened "
    LogEvt

    My database is split, but I did select the option to view hidden objects and system objects and then link the tables.

    I spent a lot of time trying to debug this, but I am not confident that I understand how this works. If you guys have any ideas, I'd be most grateful.

    Thanks,

    JoeK

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    There's a duplicate declaration in the code.
    Are you sure that you pasted the function into a standard module?

    I have attached a working example (I made a few minor improvements, but didn't change anything essential)
    Attached Files Attached Files

  3. #3
    2 Star Lounger
    Join Date
    May 2002
    Location
    Jerusalem, Israel
    Posts
    187
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='HansV' post='778697' date='07-Jun-2009 18:41']There's a duplicate declaration in the code.
    Are you sure that you pasted the function into a standard module?

    I have attached a working example (I made a few minor improvements, but didn't change anything essential)[/quote]

    Thanks. I'll give this a try.

    JoeK

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •