Results 1 to 2 of 2
  1. #1
    Dennis Eklof is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    1

    Post Exclusive Lock issue on remote database

    I am a professional Access developer and am working with another colleage on large Access project. Te ease communications and code sharing we have developed as system where each developer has an mdb to deposit new code into for the other person to import into their copy of the application. I have developed a form-driven function to import objects from the other persons repository, and that part works find. What I have not been able to do is delete the objects from the remote repository after import. I get the message "Microsoft Access can't save design changes or save to a new database object because another user has the file open. To save your design changes or to save to a new object, you must have exclusive access to the file."

    I know I have exclusive access to the file, so that is not the issue. Somehow I cannot get Access to recognize exclusive access even though I am wrapping both the copy and delete operations in Application objects. Anyone have any ideas?

    Code is below.

    Private Sub cmdImportSelectedObjects_Click()
    Dim varOBJ As Variant
    Dim Exp As String
    Exp = ExportDestination
    Dim Parts(1) As String
    Dim oType As AcObjectType
    Dim MType As Long
    Dim itExists As Boolean
    Dim strCopied() As String
    Dim strSQL As String
    Dim LongX As Long
    Dim Prompt As Integer
    Dim varx As Variant
    Dim TOID As Variant
    Dim HaveRecord As Boolean
    Dim objAccCopy As New Access.Application
    Dim objAccDelete As New Access.Application


    Const tblTO = "tblTurnedOverDoc"

    On Error GoTo ErrTrap
    objAccCopy.OpenCurrentDatabase AltReportSource, True
    For Each varx In Me!lstExport.ItemsSelected
    ResumeLoop:
    Parts(0) = Me!lstExport.Column(0, varx)
    Parts(1) = Me!lstExport.Column(1, varx)
    Typer Parts(0), oType, MType
    'Unload object if it is loaded
    If ObjectExists(Parts(1), oType) Then
    If IsObjectLoaded(Parts(1), oType) Then
    DoCmd.Close oType, Parts(1)
    End If
    'Check if backup exists
    If ObjectExists("Old" & Parts(1), oType) Then
    DoCmd.DeleteObject oType, "old" & Parts(1)
    End If
    DoCmd.Rename "Old" & Parts(1), oType, Parts(1)
    End If
    DoCmd.TransferDatabase acImport, "Microsoft Access", AltReportSource, oType, Parts(1), Parts(1)
    Next
    'Cannot seem to get exclusive access to remote database to delete files
    objAccCopy.CloseCurrentDatabase
    Set objAccCopy = Nothing
    objAccDelete.OpenCurrentDatabase AltReportSource, True
    For Each varx In Me!lstExport.ItemsSelected
    Parts(0) = Me!lstExport.Column(0, varx)
    Parts(1) = Me!lstExport.Column(1, varx)
    Typer Parts(0), oType, MType
    objAccDelete.DoCmd.DeleteObject oType, Parts(1)
    arrPush strCopied, Parts(1)
    Next
    objAccDelete.Quit
    Set objAccDelete = Nothing


    MsgBox "Successfully copied " & Join(strCopied, Comma) & " from " & AltReportSource, vbOKOnly, "Copy Successful"
    Me!lstExport.Visible = False
    Me!cmdExport.Enabled = False
    Me!lstExport.Visible = False
    Me!Procedure.Enabled = True
    Me!cmdSave.Enabled = True
    ClearFields
    ExitMe:


    Exit Sub
    ErrTrap:

    Prompt = MsgBox("Error copying " & Parts(1) & " to " & ExportDestination & ". What do you want try the next item?", vbYesNoCancel)
    If Prompt = vbYes Then
    i = i + 1
    Resume ResumeLoop
    Else
    Resume ExitMe
    End If

    End Sub
    Last edited by Dennis Eklof; 10-24-2018 at 07:01 AM. Reason: Code error fixed

  2. #2
    apr pillai's Avatar
    apr pillai is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    May 2010
    Location
    Alappuzha, India
    Posts
    209
    If any of the User ever happened to skip the normal shut down of the database then there is a chance that this message can popup.
    To check this out do the following:
    1. Ensure that the database in question is not in open state.
    2. Check the database folder for a file with the database name and file extension .laccdb (example: Database1.laccdb). You can use a text editor and check it's contents. There will be two information in it, 1. The Client machines ID, 2. the User's name.
    3. If you are sure that nobody is using the database then delete this Database1.laccdb - the file extension starting with the small letter l.
    4. After deleting this file open the database.

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

Similar Threads

  1. Replies: 8
    Last Post: 09-15-2015, 07:49 PM
  2. Exclusive access/DB lock
    By Boru in forum Access
    Replies: 18
    Last Post: 07-28-2014, 01:38 AM
  3. Database engine could not lock table issue
    By ganeshvenkatram in forum Access
    Replies: 2
    Last Post: 06-28-2011, 11:41 PM
  4. Remote Desktop Database Needs Help
    By DianeG in forum Database Design
    Replies: 4
    Last Post: 04-05-2011, 04:25 PM
  5. Remote database access
    By marleyuk in forum Programming
    Replies: 0
    Last Post: 01-15-2009, 01:43 PM

Tags for this Thread

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