Error # 3218 Could not Update, currently locked

M

M KING

I’m the only one using the database. I edit data in a form, then use the
form’s Delete button, which uses SQL to delete the record from the table.
But I can’t delete the record because I get the error:

“Could not update, currently lockedâ€

Anybody know what causes this error?
 
T

Tom Wickerath

Here is one possibility:

BUG: "Could Not Update; Currently Locked" Error Message Raised by Second
Edit Attempt in a Transaction
http://support.microsoft.com/?id=331594

To get around this bug, you can issue a Me.Undo in the Delete button’s
Click( ) event prior to deleting the record with SQL. This will release a
record lock on the edited record prior to the deletion.

If my answer has helped you, please sign in to Microsoft's Online Community
and mark my post as "Answered".

Tom
http://www.access.qbuilt.com/html/expert_contributors.html
___________________________________________

:

I’m the only one using the database. I edit data in a form, then use the
form’s Delete button, which uses SQL to delete the record from the table.
But I can’t delete the record because I get the error:

“Could not update, currently lockedâ€

Anybody know what causes this error?
 
T

Ted

here's my double click code to delete a record

Private Sub DeleteRecord_DblClick(Cancel As Integer)
On Error GoTo Err_DeleteRecord_Click
If vbOK = MsgBox("Be advised you are about to IRREVERSIBLY DELETE THIS
RECORD of this patient's (#" & Me![Patient Number] & ") !", vbCritical +
vbOKCancel + vbDefaultButton2, "Critical") Then
Me.AllowDeletions = True
RunCommand acCmdDeleteRecord
End If

i placed the me.undo command in the corresponding click command

Private Sub DeleteRecord_Click()
Me.Undo 'this inserted per kb id#= 331594 about bug in ms access
End Sub

and YET i seem to continue to get the same 3218 error message.

what's up with that?

best,

-ted

Exit_DeleteRecord_Click:
Me.AllowDeletions = False
Exit Sub

Err_DeleteRecord_Click:
'Ignore "error" if user cancels delete; otherwise
' show the error message.
If Err.Number <> 2501 Then
MsgBox Err.description
End If
Resume Exit_DeleteRecord_Click
End Sub
 
T

Ted

in my haste to get a response wrt my problemo, i absented the vba code which
when running spit out the 3218. here it is warts and all....
Private Sub Form_BeforeDelConfirm(Cancel As Integer, Response As Integer)
Dim strSQL As String
Dim db As DAO.Database
Dim qd As DAO.QueryDef
On Error GoTo Proc_Error
'see if there is a gap
If Not IsNull(DLookup("[MedNumber]", "[Concomitant Medications]", "[Patient
Number] = " _
& Me.Patient_Number & " AND [Med Number] > " & Me.[Med Number])) Then
strSQL = "UPDATE [Concomitant Medications] " & "SET [Med Number] = [Med
Number] - 1 " & _
"WHERE [Patient Number] = " & Me.Patient_Number & " AND [Med Number] > " &
Me.[Med Number] & ";"
Set db = CurrentDb
Set qd = db.CreateQueryDef("", strSQL)
qd.Execute dbFailOnError
Set qd = Nothing
End If
Proc_Exit:
Exit Sub
Proc_Error:
MsgBox "Error" & Err.Number & " in BeforeDeleteConfirm:" & vbCrLf &
Err.description ' <<<< 3218 comes at this point
Resume Proc_Exit
End Sub

best,

-ted
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top