Results 1 to 2 of 2
  1. #1
    BRZ-Ryan is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    187

    Detect on db open if someone else has db open

    I am using a local db which I will not be splitting. The intention is to only allow one person to have it open at a time to avoid entry conflicts and for speed.



    Currently, if user A has the db open and user B attempts to open it, he gets the error 'The database has been placed in a state by user 'Admin' on machine ...". This is good, as it prevents it from being opened, but I'd like to use my own msgbox error which will indicate the exact person that has it opened (in the event it's left opened unintentionally so we can track down that user). I tried to use sub main() in a module but it doesn't work. I plan to write to a table the current users name on main form load, then on form unload, delete this user. When user 2 goes to open it, I want it to say 'Currently open by user As name, try again later".

    Is there any function that gets called in VBA prior to the error above?

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Whenever the database is open, a "lock" is put on it, and a file with the same name as your database, but with a "laccdb" extension will be out there.
    So, you could create a batch file or VBScript file for users to use to run the database (instead of opening directly).
    You could have that script first check for the existence of the laccdb file, and if it exists (meaning someone already has the database open), you could have it return any message you want. The only thing is, I don't know if will be able to tell who exactly has the database open.

    I did a search, and did find this link which can be used to find out who has the database open, but it looks like it would run right from Access, and not a script file: http://support.microsoft.com/kb/285822.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 08-07-2013, 07:44 AM
  2. Help on report to open form to open query...
    By saseymour in forum Programming
    Replies: 13
    Last Post: 07-16-2013, 08:11 AM
  3. Use vba to detect if excel is open.
    By redbull in forum Programming
    Replies: 2
    Last Post: 06-17-2013, 03:07 PM
  4. Replies: 10
    Last Post: 06-13-2012, 05:57 AM
  5. Replies: 2
    Last Post: 02-26-2010, 08:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums