[VBA][Access]Making a log using text files
I would like to make a log to record what users do what at what time.
So when the database is opened it imediately accesses log.txt and begins writing lines to the text file in the format of
Date | Time | Message
19/02/2006 | 13:42 | Logon Attempt ' An example of what it would write when the logon button is pressed
How would I accomplish this in VBA.
Thanks, Emdiesse
Re: [VBA][Access]Making a log using text files
VB Code:
Open "c:\MyDbLogFile.txt" For Append As #1
Print #1, Format(Now, "mm/dd/yyyy") & " " & Format(Now, "hh:mm:ss") & " " & "Database is being opened by & " " & Enirovn("username")
Close #1
Re: [VBA][Access]Making a log using text files
Quote:
Originally Posted by Hack
VB Code:
Open "c:\MyDbLogFile.txt" For Append As #1
Print #1, Format(Now, "mm/dd/yyyy") & " " & Format(Now, "hh:mm:ss") & " " & "Database is being opened by & " " & Enirovn("username")
Close #1
How do I make it so that it loads the file from the current directory, how about if its in the current directory under a folder called logs?
By current directory, i mean the directory that the .mdb was opened from. Thanks
Re: [VBA][Access]Making a log using text files
Try out CurrentProject.Path