View Full Version : Simple Open/Close Audit Trail


___
04-05-2006, 06:10 AM
This is a very simple example of logging every time the database is opened or closed to a text file.

Durien512
04-06-2006, 01:09 PM
COOL... i am borring it!

Groundrush
04-07-2006, 06:15 AM
COOL... i am borring it!

Hi,

Please let me know when you've returned it so I can also have a look

Thanks...;)

Bigmo2u
04-12-2006, 01:07 PM
If I place this in my BE this will tell me who is in my Database on the network at all times?

Mike Hughes
04-21-2006, 03:57 AM
I don't understand how this works, but it does. Is there a way to have the log file appear on a network drive? If yes, how?

Thanks

Mike

Groundrush
04-21-2006, 06:07 AM
I don't understand how this works, but it does. Is there a way to have the log file appear on a network drive? If yes, how?

Thanks

Mike

Modify the code to show your network drive

Private Sub Form_Close()
Dim FileNum As Integer

FileNum = FreeFile

Open "C:\DatabaseLog.txt" For Append As #1
Print #1, "Database closed by" & " " & Environ("UserName") & " " & "using computer" & " " & Environ("ComputerName") & " " & ":---:" & " " & Now(); ""
Close FileNum

End Sub

Groundrush
04-21-2006, 06:22 AM
If I place this in my BE this will tell me who is in my Database on the network at all times?

Yes it will

Mike Hughes
04-21-2006, 07:30 AM
Thanks for your quick reply...I have it working.. Mike

Fear Naught
04-21-2006, 09:28 AM
I use a sumple logging table in my database but this also seems a good idea. What I can't understand is what the variable 'FileNum' does especially as it is dimensioned as an integer and its value set with what I can only assume is another integer variable that is not in the code.

Can the author please explain?

Ta

sdzc
07-25-2006, 05:45 PM
Excuse my lack of access skills on this one, but where is the code?

I cannot find it in the example database. All I see is the macro to open the form and the form itself.

WrHn85
08-02-2006, 11:30 AM
If you've opened the database you can use Alt+F11 to reveal the code. If you still can't see it, make sure the View>Project Explorer taskpane is selected and you can double click any object there to show the code. Least that's what I've been using lately...