Results 1 to 5 of 5
  1. #1
    rcima118 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Oct 2015
    Posts
    4

    Error: Could not update; currently locked. Please Help

    Hello,



    I have an access DB and I am getting the following error: Run time error'-2147467259 (80004005) Could not Update; currently locked

    I think it has to do with accessing the current record, modifying it, and then reverting back to that same record with some sql code to edit it. The VBA is below:

    Private Sub ContactID_AfterUpdate()


    Dim intContact, curMember As Integer
    Dim rst As New ADODB.Recordset
    Dim conn As ADODB.Connection

    If Me.Form.Recordset.RecordCount > 1 Then
    If Me.Form.Recordset.AbsolutePosition = 0 Then
    If MsgBox("Do you want to update ALL parcels to this secondary contact?", vbYesNo, "Update All?") = vbYes Then
    intContact = Me.ContactID.Value
    curMember = Me.MemberID.Value
    Set conn = CurrentProject.Connection

    rst.Open "UPDATE tbl_Parcels SET tbl_Parcels.ContactID = " & intContact & _
    " WHERE MemberID = " & curMember, conn, adOpenDynamic, adLockOptimistic

    Set rst = Nothing

    Me.Requery
    Me.Refresh

    End If
    End If
    End If


    End Sub


    The part in red is where the debugger is hanging. I also read a thread that said I might be directing it to the wrong library type. Any help is appreciated, I think it is probably something simple that I am missing.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Is the ContactID control bound to field?

    Try:
    Code:
    Private Sub ContactID_AfterUpdate()
    If Me.Form.Recordset.RecordCount > 1 Then
        If Me.Form.Recordset.AbsolutePosition = 0 Then
          If MsgBox("Do you want to update ALL parcels to this secondary contact?", vbYesNo, "Update All?") = vbYes Then
             DoCmd.RunCommand acCmdSaveRecord
             CurrentDb.Execute "UPDATE tbl_Parcels SET tbl_Parcels.ContactID = " & Me.ContactID & " WHERE MemberID = " & Me.MemberID
          End If
       End If
    End If
    End Sub
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    rcima118 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Oct 2015
    Posts
    4
    Hello,
    That actually seems to work, and let me say thank you so much. I have another entry cell next to it on the form, performing the same function, just into a different column. I figured I could just copy and paste the VBA in, and change the appropriate items:

    Private Sub Type_AfterUpdate()
    If Me.Form.Recordset.RecordCount > 1 Then
    If Me.Form.Recordset.AbsolutePosition = 0 Then
    If MsgBox("Do you want to update ALL parcels to this Landowner Type?", vbYesNo, "Update All?") = vbYes Then
    DoCmd.RunCommand acCmdSaveRecord
    CurrentDb.Execute "UPDATE tbl_Parcels SET tbl_Parcels.Type_1 = " & Me.Type_1 & " WHERE MemberID = " & Me.MemberID
    End If
    End If
    End If
    End Sub

    So that is what I did, you can see all I did was change the column mane to Type_1, as opposed to contactID. I now get the following error: Too few parameters. Expected 1
    The red area is where the debugger is hanging.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    What data type is Type_1 field? Why does field name have a _1 suffix?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    rcima118 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Oct 2015
    Posts
    4
    Type_1 is just "short text". It has the _1 for no apparent reason. It was named that prior to me working on this DB. I could change it, but I would have to do so throughout many forms and queries. Any idea why this is happening? It is strange because the change in code worked just fine for the other field.

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

Similar Threads

  1. Can't update record, currently locked
    By clancy76 in forum Access
    Replies: 5
    Last Post: 04-16-2015, 10:20 AM
  2. BeforeUpdate: Could not update; currently locked.
    By v7davisa in forum Programming
    Replies: 3
    Last Post: 09-26-2014, 04:18 PM
  3. Could Not Update, Currently Locked
    By jlclark4 in forum Forms
    Replies: 5
    Last Post: 11-17-2011, 01:21 PM
  4. Err# 3218: Could not update; currently locked.
    By reachvali in forum Access
    Replies: 3
    Last Post: 06-30-2011, 05:13 PM
  5. Error: Can not update record; currently locked
    By waldzinator in forum Programming
    Replies: 4
    Last Post: 03-29-2011, 08:40 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