Allow exclusive access only

R

Rob

Is there a programatic way to allow only 1 user at a time to exclusively
open an mdb ?

Example: If someone else is using the mdb, then give the new user, who is
attempting to open the mdb, a message stating that ... "Fred is currently
using the db" ?
 
B

Ben Silvert

One way to do this would be to append a row into a table in the database that
would keep track of who has opened the database. That code would be triggered
when the startup form is opened. If there already was a name in the table,
then the application would let the user know who has the database open, and
then close.

The unload event of the startup form should remove the name of the user from
the table.

You may want to keep the date of when the user logged into the database in
that table as well; someone may leave the database open and go home without
closing the database. It gets a little sticky here. If the date is older than
a day, maybe delete the old log record and let the new person in.

A problem with the solution is that a user could open the database with the
shift key down. You should disable that from happening.

Method 2.

Another way to do this would be to write the name of the logged in user to a
file. Anybody else that opens the database first reads the file, if it
exists. The database then closes if the file exists. Then what you could do
is have the users not open the database directly, but run a vbscript file
that would check for the existence of the user log file first. If there were
none, then the script would make and write to the file, and open the
database. When the database closes, it would delete the file.

Hope this helped.
 
R

Rob

Thanks Ben,

I give the first method a try...


Ben Silvert said:
One way to do this would be to append a row into a table in the database
that
would keep track of who has opened the database. That code would be
triggered
when the startup form is opened. If there already was a name in the table,
then the application would let the user know who has the database open,
and
then close.

The unload event of the startup form should remove the name of the user
from
the table.

You may want to keep the date of when the user logged into the database in
that table as well; someone may leave the database open and go home
without
closing the database. It gets a little sticky here. If the date is older
than
a day, maybe delete the old log record and let the new person in.

A problem with the solution is that a user could open the database with
the
shift key down. You should disable that from happening.

Method 2.

Another way to do this would be to write the name of the logged in user to
a
file. Anybody else that opens the database first reads the file, if it
exists. The database then closes if the file exists. Then what you could
do
is have the users not open the database directly, but run a vbscript file
that would check for the existence of the user log file first. If there
were
none, then the script would make and write to the file, and open the
database. When the database closes, it would delete the file.

Hope this helped.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top