AHAXtreme
asked on
MS Access Maintaining a log of users who log in and what time they log in.
I put user level security on my database.
How can I maintain or review of log of who logged in and what time they logged into the database?
How can I maintain or review of log of who logged in and what time they logged into the database?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Just about every office as different logins for each user. I have run across a few that use the generic Admin login on all their computers. If you are in a case like this then you can not use CurrentUser. You would have to create a login screen and use the textbox they type their name instead of CurrentUser in Ricks answer.
ASKER
I put in my autoexec macro a runcode option with your code CurrentDb.Execute "INSERT INTO tblUserLog ([User]) VALUES ('" & Replace(CurrentUser(), "'", "''") & "')"
And I get the following error.
Microsoft Office Access can't find the name CurrentDb you entered in the expression.
Please advise.
And I get the following error.
Microsoft Office Access can't find the name CurrentDb you entered in the expression.
Please advise.
ASKER
Thanks
Glad you found the answer you were looking for.
If you wanted to run the code...
CurrentDb.Execute "INSERT INTO tblUserLog ([User]) VALUES ('" & Replace(CurrentUser(), "'", "''") & "')"
In a macro it would have to read...
=CurrentDb.Execute("INSERT INTO tblUserLog ([User]) VALUES ('" & Replace(CurrentUser(), "'", "''") & "')")
This however is not desireable as it will likely log the entry twice. A better method is to move the code into it's own function such as the code snippet below then within the macro set it to runcode and name the function as follows
=LogUser()
If you wanted to run the code...
CurrentDb.Execute "INSERT INTO tblUserLog ([User]) VALUES ('" & Replace(CurrentUser(), "'", "''") & "')"
In a macro it would have to read...
=CurrentDb.Execute("INSERT
This however is not desireable as it will likely log the entry twice. A better method is to move the code into it's own function such as the code snippet below then within the macro set it to runcode and name the function as follows
=LogUser()
Function LogUser()
CurrentDb.Execute "INSERT INTO tblUserLog ([User]) VALUES ('" & Replace(CurrentUser(), "'", "''") & "')"
End Function