Results 1 to 3 of 3
  1. #1
    AKQTS is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jul 2010
    Posts
    56

    Open Exclusive Code

    You know how you can open a database as exclusive (lock other users out) by opening an access file through the file browse dialog and selecting the option?

    I want to do that when I open my file without going through the opening procedure. I.E. when i double click on the icon for the program, I want it to run as exclusive (lock everyone else out) without opening through the file browser and setting that property.

    I tried Accesss Options-Advanced- (checked)Open Exclusive
    and no change, still lets any other user open and use the program.

    I don't want to check for a lock file.

    Is there any code to just set the database to exclusive on open?



    Thanks, I thought this would be easy

  2. #2
    AKQTS is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jul 2010
    Posts
    56
    Solved my own problem, maybe not the best, but it works:

    Sub work()
    On Error GoTo work_err
    Dim myWorkspace As Workspace
    Dim myDatabase As Database

    Set myWorkspace = DBEngine.Workspaces(0)
    Set myDatabase = myWorkspace.OpenDatabase(Name:="<filepath>", Options:=True, ReadOnly:=False)
    work_Exit:
    Exit Sub
    work_err:
    MsgBox "Database is open by another user, please try again later", vbCritical, "In Use"
    Application.Quit
    Resume work_Exit
    End Sub

  3. #3
    AKQTS is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jul 2010
    Posts
    56
    An even easier solution is to also just add /excl after the file path if you are creating a shortcut.

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

Similar Threads

  1. Exclusive access/DB lock
    By Boru in forum Access
    Replies: 18
    Last Post: 07-28-2014, 01:38 AM
  2. exclusive mode
    By raffie77 in forum Access
    Replies: 7
    Last Post: 01-24-2012, 10:27 PM
  3. Form Code refresh on open
    By mseeker22 in forum Forms
    Replies: 2
    Last Post: 07-08-2011, 12:35 AM
  4. Replies: 21
    Last Post: 02-14-2011, 02:51 PM
  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