Applecore Pages on Microsoft Access

Keeping track of who is logged into a Database

If you need to know who is currently using the database at the moment, then probably the best option is to control it yourself. Although the ldb file that is created normally by Access does list the names of the machines that have logged into the database, this list is not reset until the database is closed by the last user, and in some cases the ldb file may not be deleted.

If you wish to do this, then you will need to create a table, such as tblUser, that has the required fields including UserName. You may also wish to include the time that the user starts using the database as well. In a database that has been split, this table should be placed in the back-end database. You will need to create a form that is loaded when the database starts, and remains hidden. In the OnLoad event for the Form, you will add a record to the table, and in the OnUnload event you will delete that record. If you are not using Access security, then you can get the user's OS login name using an API call, as shown at The Access Web.

Private Sub Form_Load()
    CurrentDb.Execute "INSERT INTO tblUser (UserName) VALUES(" & Chr(34) & fOSUserName & Chr(34) & ");"
End Sub
 
Private Sub Form_Unload(Cancel As Integer)
    CurrentDb.Execute "DELETE * FROM tblUser WHERE UserName=" & Chr(34) & fOSUserName & Chr(34) & ";"
End Sub

Top

 


HOME | NEW | TABLES | QUERIES | FORMS | REPORTS | GENERAL | API | DOWNLOADS | TUTORIAL | RESOURCES
E-MAIL
Copyright & Disclaimer

 

Last modified at 06/06/2006 14:57:18