Check for Database Currently Running

K

Kat

Hi all,

Is there a way to check to see if a specific database is currently open on
the same computer using a different database?

ie I want to check from database 2 if database 1 is open on that computer
(and only on that computer).

I know I could check for len(.ldb)>0, but the .ldb file would not tell me
that the specific computer I want to check from has the database open only
that someone does.

I use access 2003 although all the databases are saved in access 2k. Both
databases in question reside on a network drive and could be in use by
someone else in the building.

Thanks for any help in advance.

Kat
 
K

Kat

Hi Jon,

First of all, thanks for your response.

That would seem to work if I was looking for who was in database 2 (the
current database) but how would I use that to check for database 1 being open
on that computer without opening another instance of database 1 therefore
defeating the purpose?

I probably wasn't specific enough, the ultimate aim is to check from
database 2 if database 1 is open on the computer so that I can create an "If
then else" statement not to open database 1 if it is already open when an
event happens in database 2.

Database 1 has some "automatic" code that runs, and I don't want it to be
running in two instances on the same machine. The main reason for not
checking for the .ldb file is that database 1 may not have closed correctly
and may not actually be open even with an .ldb file in existance.


Kat
 
J

Jon Lewis

You can run the procedure in database2 to check the user roster of
database1. This in itself will show one user from the computer connected to
database1. But this (as far as I'm aware) in itself won't 'Open' the
database - no autoexec macro will run. If database1 was already open, then
checking the user roster using a fresh ADO connection will reveal 2 users
from the computer in the roster.

Loop through the rs, count when Left(rs.Fields(0), InStr(rs.Fields(0),
vbNullChar) - 1) = strComputerName
If the count > 1 then the database is already open

HTH
 
K

Kat

Ah Yes, my fault, I didn't look close enough at the code to see that you
specify the database to look at and therefore I could look at the users in
database 1 from database 2. This is going to take a bit of work to make it
fit to what I would like it to ultimately do, but it should work.

Thanks a bunch.

Kat
 

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