Record Lock Error

I had a user get an error

"Error 3218 (could not update; currently locked.) in Procedure writePropertyComment of Module modEven_Import_Export_Comments

This message is generated by the application custom error handler (code below).  In the case of a locked record I thought there was a time period the record being inserted waits for the lock to free before generating an error.  Is that correct?

The message was generated out of the following routine, on the Insert command

Public Sub writePropertyComment(passedPropertyID As Long, _
                                passedComment As String, _
                                Optional passedUserName As String = "", _
                                Optional passedCommentTypeID As Long = 1, _
                                Optional passedBRT As Long = 0)
'

'- - - - - - - - - - - - - - - - - - - - - - - - - - G E N E R A T E D  E R R O R  C O D E ----------------
'                          
                               If IsDeveloper Then
                               Else
                                 On Error GoTo writePropertyComment_Error
                               End If
'- - - - - - - - - - - - - - - - - - - - - - - - - - G E N E R A T E D  E R R O R  C O D E ----------------
'
Dim wkUserName As String
Dim wkDateTimeAdded As Date
wkDateTimeAdded = Now

'
If Len(Trim(passedUserName)) > 0 Then
    wkUserName = passedUserName
Else
    wkUserName = GimmeUserName
End If

' add the comment
'
DoCmd.SetWarnings False
'
CurrentDb.Execute " insert into tblProperty_Comments " & _
              "( [BRT], [PropertyID], [CommentTypeID], [Comment], [DateAdded], [UserAdded]   )  " & _
  "   values(" & passedBRT & _
          ", " & passedPropertyID & _
          ", " & passedCommentTypeID & _
          ", " & Chr(34) & Replace(passedComment, Chr(34), Chr(34) & Chr(34)) & Chr(34) & _
          ", " & Chr(35) & wkDateTimeAdded & Chr(35) & _
          ", " & Chr(34) & wkUserName & Chr(34) & _
          ")", dbFailOnError

'- - - - - - - - - - - - - - - - - - - - - - - - - - G E N E R A T E D  E R R O R  C O D E ----------------
                               On Error GoTo 0
                               Exit Sub
writePropertyComment_Error:
                               sysErrorHandler Err.Number, Err.Description, "writePropertyComment", "modEvent_Import_Export_Comments", "Module"
'- - - - - - - - - - - - - - - - - - - - - - - - - - G E N E R A T E D  E R R O R  C O D E ----------------

End Sub


Here is the Error Handler

Public Sub sysErrorHandler(passedErrNum As Long, _
                            passedErrDesc As String, _
                            passedRoutine As String, _
                            passedModuleName As String, _
                            passedModuleType As String)
'
 
'
Dim wkErrUser As String
Dim wkErrDateTime As Date
Dim wkFullErrDesc As String
'
wkErrUser = GimmeUserName
wkErrDateTime = Now
'
wkFullErrDesc = "Err Desc: " & passedErrDesc & ", Routine: " & passedRoutine & ", Module: " & passedModuleName
'
DoCmd.SetWarnings False
'
CurrentDb.Execute " insert into tblErrorLog " & _
              "( [ErrNum], [ErrText], [ErrUser], [ErrDateTime]  )  " & _
  "   values(" & passedErrNum & _
          ", " & Chr(34) & wkFullErrDesc & Chr(34) & _
          ", " & Chr(34) & wkErrUser & Chr(34) & _
          ", " & Chr(35) & wkErrDateTime & Chr(35) & _
          ")", dbFailOnError


gResponse = MsgBox("An error has occurred in your application.  The specific error is:  " & vbCrLf & vbCrLf & _
   "Error " & passedErrNum & " (" & passedErrDesc & ") in Procedure " & passedRoutine & " of " & passedModuleType & Space(1) & passedModuleName & vbCrLf & vbCrLf & _
   "Please copy down the error information on the above lines or take a screen snapshot so you can supply this information when you contact tech support." & vbCrLf & vbCrLf & _
   "Tech support" & vbCrLf & _
   "When you press the ""OK"" button you will exit the system.", vbCritical + vbOKOnly, "Unrecoverable System Condition")
   '      
      Application.Quit acQuitSaveNone


 
End Sub
LVL 1
mlcktmguyAsked:
Who is Participating?
 
Gustav BrockCIOCommented:
> I thought there was a time period the record being inserted waits for the lock to free
> before generating an error.  Is that correct?

No. You will handle that yourself. One simple method is reread the data to be updated (this may happen automatically in case of a simple write conflict) and try again once or more.
If the lock persists for an extended time, you may have to skip your update for this time.

Most likely, your error handler can't handle this - if for no other reason that there is no right or wrong method to handle this - it depends on your application.

/gustav
0
 
Jeffrey CoachmanMIS LiasonCommented:
custom error handler
Try commenting out the custom error handler, and see what you get, ...then go from there...
0
 
mlcktmguyAuthor Commented:
Thanks
0
 
Gustav BrockCIOCommented:
You are welcome!

/gustav
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.