Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Menu to notify users regarding Exclusive mode

Status
Not open for further replies.

Tamrak

MIS
Jan 18, 2001
213
US
Good morning,

I have question that I am unsure whether anyone can create a VBA code.

I have a shared database that is working fine by several users. Sometimes, a specific user needs to conduct a maintenance, which requires everyone to get out from the Access program.

I would like to create a simple procedure. For example, the menu might be called -> "check exclusive." This can be done with a click button.

If no one is using the database at that moment, except for that specific user, return the message -> "No one is using the database at this moment."

If there is one or more persons using the database, return with the message -> "Database is currently occupied." For the beauty of it, if I can have the user's names of the persons who are in the db, that will be fabolous. However, if it is too difficult, I am OK with it. This is not required.

Thank you for your time.

 
You wont be able to return the users name, but you should be able to check if anyone is in the db by examining the ldb file. Check out this KB article for info on how to read the ldb file.




------------------------
Hit any User to continue
 
Why not use the fact that when a db is opened exclusively, no ldb file is created, e.g.
Code:
Function fctnExcl() As Boolean
Dim fs
Set fs = CreateObject("Scripting.FileSystemObject")
fctnExcl = Not fs.FileExists(Replace(CurrentDb.Name, ".mdb", ".ldb", , , vbTextCompare))
End Function
fctnExcl will return True if the db is opened exclusively, otherwise False. The function can be used anywhere you like, including from a menu item.

[pc2]
 
mp9..

Doesn't an ldb file always get created?

The the user who is trying to ascertain if any other users are in the database will have a lock on the DB.. thus this function will always return true, as the ldb file will have been created by the user calling the function.



------------------------
Hit any User to continue
 
Well that's what I always thought. Buit I just tried opening a db exclusively now in A2002 and no ldb was created. Anyone else care to comment on why this is so, and if this can be used to test exclusivity?

[pc2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top