Who is using my database

When you need to edit a database in a large organisation where you have multiple users you have a number of options

1. kick them out using the server close files option
2. Look up the ldb file to see who has the file open

The problem with the second issue is the LDB file only stores the computer name and not the username or login.

My option is to store the computer and username when the user logins to the system. Create a table in the application ( not in the linked database) and add the columns ComputerName and UserName as text fields call the table tblUsers.

On your main form add an on open event as follows

Dim rst As Recordset
Set rst = CurrentDb.OpenRecordset("select * from tblUsers where ComputerName=" & Chr(34) & Environ("COMPUTERNAME") & Chr(34))
If rst.RecordCount = 0 Then
    'add the user
    rst.AddNew
    rst!UserName = Environ("UserName")
    rst!ComputerName = Environ("ComputerName")
    rst.Update
End If
Set rst = Nothing

When you need to update the program you will be able to identify any active users.
Another method to use involved having a hidden form which I will cover and cross link at a later date.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply