View Full Version : Logging User Names In Access
garydp
10-30-2015, 02:09 AM
I have a password protected access .mdb file.
is there a way of logging who has opened the file and what time the file was opened when the password is entered?
I think that someone has somehow managed to work out the password and want to see who is logging on
the file is accessed by an excel spreadsheet by multiple users but I only want to see who has opened the file manually.
thanks
Create a table 'log' with a field usr with 'indexed' property set to 'Yes (No Duplicates)'
add this code to a module
Public Function log()
On Error Resume Next
DBEngine(0)(0).Execute "insert into log (usr) values ('" & Environ("username") & "')"
End Function
create a macro called 'autoexec'
Action = RunCode
Arguments = log()
The log table will record names of anybody that opens the database.
InLaNoche
10-30-2015, 08:31 AM
nice. I assume that the macro is run on opening the db?
A macro named autoexec will run automatically when you open the database - unless you hold down the shift key, so you kind of have to hope they don't know too much about Access.
InLaNoche
10-30-2015, 11:34 AM
Kool. In the past I have created a splash screen that would run the macros needed. Good to know.
garydp
10-31-2015, 01:54 AM
excellent, how to add to this to add the date and time?
Thanks
Add your field and change the sql
"Insert into log (usr,yourdatefield) values ('" & environ("username" & "'), now())"
It'll only record the first login though unless you make the user field not indexed.
I changed the Thread Title for easier searching
garydp
11-03-2015, 02:11 AM
excellent thanks
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.