1st question: one solution would be to add a UsageLog table to the db. 3
fields: Username, UserTime and UserAction. When opened, log a record with
UserName, Date/Time and "Log In". Same idea when closing (except "Log Out").
Build a query that shows Max(UserTime) and UserName from the log. In another
query, attach the LastAction result to the usage table by Timestamp &
Username, then add the associated action. Result should be a list of all
users & what their very last action was. Anyone with an action other than
"Log Out" is either still in or terminated abnormally.
You can of course log other actions to this table as well (Using advanced
features, supplying an internal password, failing to provide said password,
etc.)
This log has come in handy more than once. In one case, a client called me
in because the db had become corrupt. Looking at the UserLog, I noticed that
the last person in before corruption had never logged out (i.e., an abnormal
termination). Looking further, this user had a LOT of abnormal terminations.
When asked, he reported that the app was hanging every time he tried a
specific action, so he bailed out. I was able to recreate & fix the problem
(an pretty much endless loop under certain conditions) but i wouldn't have
even have known to ask him without the log. (Had he reported the problem to
anyone? Of course not...)
http://mvps.org/access/api/api0008.htm has code to retrieve the current
network (i.e., Windows) user name.
2nd question: probably the .ldb file wasn't deleted after the last user
logged out. As long as the .ldb file exists, you won't be able to open
exclusively since its mere presence tells Access that the mdb is already in
use (it doesn't care by whom at this point). Also, I believe the ldb file is
"owned" by whoever created it (i.e., the first user) until it is destroyed
by the last person logging out (even if the original "opener" logged out &
went home hours ago). Might be wrong about that, but that's my
understanding.
HTH