The code I use is:
- Code: Select all
Function IsRecordLocked(ThisID As Long) As Boolean
Set rst = CurrentDb.OpenRecordset("tblContacts", dbOpenDynaset)
.FindFirst "[ID]=" & ThisID
If Not .NoMatch Then
Else 'Can't find this person so create error
Err.Raise vbObjectError + 513
End With 'rst
If Err.Number = 0 Then
IsRecordLocked = False
IsRecordLocked = True
Most times this seems to work but occasionally it doesn't work - the .Edit and .Update don't generate an error if the record is locked. Hence IsRecordLocked returns false. I suspect that the times it works must be when the record isn't locked.
Is there a better way? If not how can I make this one work - without actually writing data.