# VBA Code to retrieve a list of users logged into Access



## JJ06 (Apr 1, 2011)

Hello, im trying to write some VBA code that will allow me to see all the users that are logged into my public Access 2003 database. They are only using the database to fill out a form and i would like to have visibility as to who is logged in. I have the database stored out on a public drive so multiple people can be in creating records at any given time. But in order for me to make any changes to a table on the back end, i need to kick whoever is logged in OUT and a list would help me contact them. Any suggestions are greatly appreciated. Also, im still pretty novice at writing VBA. Thanks.


----------



## OBP (Mar 8, 2005)

JJ06 welcome to the forum.

You can open the .ldb to see who is in the database, you can even use Word or Wordpad to open it .
However there may be a better technique which involves closing the database after providing them with a warning message in Access. It would have a hidden form that uses the Form's on timer event procedure to periodically check a table in the database, or an external text file. If you enter the appropriate text in the table or folder it displays the message, waits for a certain length of time and then closes the database.


----------



## JJ06 (Apr 1, 2011)

Thanks... this worked... also im looking for a way to post a message telling everyone in the database that routine maintenance needs to be done and to save the record that they are currently working on and exit. Any ideas??? Thanks again.


----------



## OBP (Mar 8, 2005)

As I outlined in post #3, you use a hidden form that is opened when the database opens.
I will see if I can create you an example.


----------



## OBP (Mar 8, 2005)

Here is the test database.
Downlload and Unzip the database.
Open the database and a form called form1 will open in hidden mode, it is checking the table called Closedatabase.
Open that table and tick the close database check box.
After a short delay a form with a message will appear, wait about 20 or 30 seconds and the forms and database will close.
To change the waiting time to 5 minutes change this line of code on the Message form's VBA code 
Me.TimerInterval = 10000 ' change to 300000 for about 5 minutes
change the 10000 to 300000


----------



## JJ06 (Apr 1, 2011)

Thanks... this works great.


----------

