Error 3218

AdamAA

Registered User.
Local time
Today, 02:42
Joined
Aug 18, 2012
Messages
24
I have some VBA code that clears checkboxes and text boxes on a continuous form, then closes the form.

The problem is whenever the code reaches the record that I edited last, it throws up the error "Error Number: 3218 Could not update; currently locked" It will happily adjust all the other records that I've edited, it's just the most recent one that I last edited that it hangs on.

Here's the code:

Code:
Private Sub Command182_Click()
On Error GoTo ErrorHandler
 
Dim db As Object
Dim rst As Object
 
Set db = Application.CurrentDb
Set rst = Me.RecordsetClone
 
rst.MoveFirst
 
    Do Until rst.EOF
            rst.Edit
            rst!CertFilter = False
            rst![A Defect] = ""
            rst![B Defect] = ""
            rst![C Defect] = ""
            rst![A Defects Comments] = ""
            rst![B Defects Comments] = ""
            rst![C Defects Comments] = ""
            rst.Update
            rst.MoveNext
 
 
          Loop
 
rst.Close
 
DoCmd.Close acForm, "Lifting Equipment Main"
DoCmd.OpenForm "MainInventory", acNormal
Exit Sub
 
ErrorHandler:
MsgBox "Error Number: " & Err.Number & " " & Err.Description
End Sub

The table is pulling from a query, not a table.
 
Try adding this before Set lines:

If Me.Dirty Then Me.Dirty = False
 
Now this code works, but only if after editing the last record, I click on another one and don't edit it. Otherwise I get the same error.

Thanks for your reply. By the way I love baldyweb, I use it all the time :)
 
Curious, because what you're describing would save the edited record when you went to another, which is what that code should do. Can you post the db here?

Thanks, glad it helps you!
 

Users who are viewing this thread

Back
Top Bottom