Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Who is logged on? 1

Status
Not open for further replies.

ddmtn546

Technical User
Dec 20, 2000
38
US
When a user logs on to Access 2000, a lock file is opened. Typically a user does no close the DB at the end of the day. Of course then when trying to perform maintenance, I get an error stating that I don no have exclusive access to the DB. The machines are spread around the property. Is there any way to log off each user so I could gain exclusive rights? Thanks in advance, ddmtn546.
 
Firstly, I'm assuming you want to carry out maintenance on one central database which all these user are acessing.
There's no easy way I know of.
You could try playing round with timer intervals to make the database quit after x hours of inactivity. You could also use this OnTimer event to make all database log out at a certain time in the evening.
But probably the best would be to create a centrally accessible table(tblAppAccess) with one record and one field (AccessAllowed) of type Yes/No. Default this to 'Yes'

Set the Timer Interval on the main form of your database to something very frequent, like every 30 seconds. The set the OnTimer event to look up this table, if the value of 'AccessAllowed' is set to 'No' then run the code
Code:
Docmd.quit
which will close Access.
When you want to do your maintenance, you set the value of this table to 'No'.

Also, I am assuming that there is a main form opened when the user open the database, and that this stays open throughout their session.
 
Thanks SaraG, interesting thought, I will give it a try - Thank You very much - ddmtn546.
 
Hi,
I am not sure if this is helpful, but you can read the "ldb" file and find out who is still logged on. Be aware that you can open this file in Notepad, but it is unreadable. Microsoft Word will be able to read it.
HTH,
Randy Smith
California Teachers Association
 
Thanks randysmid, I will give it a look. ddmtn546
 
Microsoft has made a utility called "LDBView" specifically for the purpose of looking at the contents of an LDB file. The LDBView executable is part of the JetUtils download. Check the Microsoft Knowledgebase Article 176670, or search for Jetutils on the Microsoft website. (The article says the program is for Access 97, but I've used it with Access 2000 without problems. I haven't tried it with XP.)
 
You can also go to From there go to Access 2000 Sampple Library, then locate LogUsersOff2K.mdb (all the samples are in alphabetical order). He also has a sample for non A2K.

This example database shows you how to log ALL users off. The gist is this.

In your front end, create a form with no controls and open it hidden when the database starts. In the Back end, create a table with a logoff ysn checkbox. Set the timer event for the form that you opened in the front end to periodically check the value of the check box in the logoff table (every 5 minutes or so - because remember - the timers are not that accurate). When you need to get into the database, change the value in the logoff table to true. The hidden form timer event will fire, see that your value says yes, then you could perform some action. In my applications, when the logoff table says yes, another form is opened notifying the user that the database will be closed in 5 minutes. This gives them ample time to do whatever they need to do. After 5 minutes, the database closes. The logoff table still says yes. I check for this when a user logs in. If that value is yes, they are given a msgbox stating that the database is temporarily unavailable and to try again later - so it keeps users out as well. but REMEMBER - YOU MUST RESET THAT LOGOFF TO NO WHEN YOU ARE FINISHED - speaking from TOTAL experience!! I finally ended up writing a small block of code that when I am finished, it sets the value to no, then emails all the users of the database that it is now available. You can get the example database and download it and see everything. It works FANTASTIC!!!!

Hope this helps.

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top