The application.compactrepair will work
and for the other part that you need
Try this link:
http://www.mvps.org/access/modules/mdl0055.htm
it has a small access app that looks at the ldb file and will tell you
all of the users that are logged into mdb that you reference.
really neat and small, and the code for the form can be imported into
any app that you want or run standalone out of this app.
With this whole process you may want to
1) rename the tables file so that noone can get into it are even start
while you are compacting it.
2) make a backup
3) do the compact on one of those two files
4) rename the one you compacted back to the original.
Consideration.
If that mdb is on a mapped drive BUT that drive is actually on a
separate server, you may want to try it and consider the time it will
take. Cross server processes tend take a L O N G time and may end up
causeing more errors than they fix. Having someone on that server
actually do it may be the wiser solution.
What we did here we we had to do it was rename, copy to our server,
compact and repair copy back to other server as proper name That
actually took less time and definitely had less errors than we
encountered when we tried the compact across the servers.
Ron