The code I use is:
- Code: Select all
Function IsRecordLocked(ThisID As Long) As Boolean
....
....
Set rst = CurrentDb.OpenRecordset("tblContacts", dbOpenDynaset)
With rst
.FindFirst "[ID]=" & ThisID
If Not .NoMatch Then
.Edit: .Update
Else 'Can't find this person so create error
Err.Raise vbObjectError + 513
End If
End With 'rst
If Err.Number = 0 Then
IsRecordLocked = False
Else
IsRecordLocked = True
End If
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.

