G
Guest
Does anyone have some good code for checking to see whether or not a file is
locked in VBA/Access?
I am needing to do 2 different things here:
1) Check a text file to see if it is locked by another user before opening
it with a FileSystemObject to avoid errors.
2) Check an Access database to see if it is locked before opening it.
Note: I've figured out that just checking for a .ldb file is insufficient
for checking for a locked Access database. If I have read-only access to a
directory holding a database and open that db, it will tell me that I have
read-only access. When someone else with read access attempts to open it,
despite if there's a lock file or not (in this case there won't be one), they
will still get a read-only message.
If the file is locked by a user on the network, I want to be able to get
their user name (I imagine this is done via a win32 api call since you can do
"dir /q" from a cmd prompt and get the process owner), and then shoot them a
message telling them politely to get out, then wait for the file(s)/db(s) to
be available.
locked in VBA/Access?
I am needing to do 2 different things here:
1) Check a text file to see if it is locked by another user before opening
it with a FileSystemObject to avoid errors.
2) Check an Access database to see if it is locked before opening it.
Note: I've figured out that just checking for a .ldb file is insufficient
for checking for a locked Access database. If I have read-only access to a
directory holding a database and open that db, it will tell me that I have
read-only access. When someone else with read access attempts to open it,
despite if there's a lock file or not (in this case there won't be one), they
will still get a read-only message.
If the file is locked by a user on the network, I want to be able to get
their user name (I imagine this is done via a win32 api call since you can do
"dir /q" from a cmd prompt and get the process owner), and then shoot them a
message telling them politely to get out, then wait for the file(s)/db(s) to
be available.