Discussion Locked

Microsoft Access Databases

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
Does a Access database have a easy way to put a log on.Iam looking for a way to log users that have been in the database that day.Can someone tell me how to configure that.

7 replies

by c1980

You could create a table that has 2 fields: a User name field and a DateTime field.

The set a macro name "AutoExec" which will start each time the database is opened, that calls, (RunCode), a function, Public Sub UserLogOn(), created by you in a module. This function creates a recordset and opens the above table and adds a new record, setting the UserName field to CurrentUser() and the date field to Now():

rsUser!UserName = =CurrentUser()
rsUser!LogOnTime= =Now()

'===================================
Or make it mor simple Create the tables and in the AutoExec macro add the following 3 commands:

WarnMessages =Off
RunSQL = Insert Into UserLogOn Values (CurrentUser(),Now())
WarnMessages = On

by donq

I do very much the same thing as answer 1 however I place a "UserID" and "LastChange" field at the end of each record in every table and use each Form's After Update event to set UsedID to CurrentUser() and LastChange to Now(). I know who and when each change is executed, and with a little work existing values can be archived before any updates are made.

by bob sellman

As noted in the above answers, you must program this capability yourself. I use a standard login form I created that uses data from a UserList table to verify the userID and password. You could create a second table (LoginActivity) that would postthe userID, date/time, activity (logged in or logged out).

Don't forget to also put something in your application that will also post a record to LoginActivity when a user exist the application, otherwise you won't know when they are out of the application. Or you could have two fields: date/time logged in and date/time logged out and post to the one record when the user logs out.

To do more with the User login, create a macro with at least one public variable: strUserID. Post the UserID to strUserID when logging in. You can then control access to different functions based on the UserID (or based on a security level group identified with each user in the user list table). This could also be used if you want to create the trackingdetail capabilities metnioned in the second answer where you post the last userID to change a specific record to that record.

You need to be sure that users do not have access to such things as the X in the control box (upper right corner) of each window/form and can only quit the application one way. Otherwise, they might exit the application in ways that do not post the logged off data.

This discussion is closed to new replies.