Pessimistic Record Locking

N

N. Cotton

I currently use Pessimistic Record Locking and test if a current record is
locked using the function below.

If the record is locked by another user, error #3218 is correctly triggered.

The problem I have is the time it takes to actually trigger this error. If
the record is not locked, the function returns instantly. However, if the
record is locked, the system takes around 5 seconds to trigger the error.

1) Is there a way to speed up the trigger of this error?
2) Is there a better way to test if a record is lcoked by another user?

Many thanks.

This is the function I use to test if the record is locked. The recordset
passed is a single record:

Public Function IsRecordLocked(rs As Recordset) As Boolean

'Returns True if the record is locked for editing by another user
'rs = testing reecordset

IsRecordLocked = False

With rs
On Error GoTo Err_Lock
.Edit
.Update
On Error GoTo 0

End With

Exit Function

Err_Lock:
If Err.Number = 3218 Then
IsRecordLocked = True
End If
Resume Next

End Function
 

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