Hi
Just to clarify - what I was looking to do was detect in a form if the record the user was about to edit, was locked by another user.
I came up with the following (note I am using DAO, you could change declaration of Rs if you are using ADO)
In the OnClick of my Edit Button:
If IsLocked(Me, True) Then
'
Else
ButtonsAtSelect '< enables/disables buttons
FieldsLocked False '< locks/unlocks controls on form
End If
in a public module put:
Public Function IsLocked(frm As Form, Optional blnMessage As String) As Boolean
Dim Rs As DAO.Recordset
Dim blnMsg As Boolean
Dim strMsg As String
'
On Error GoTo Error_IsLocked
If IsMissing(blnMessage) Then
blnMsg = False
Else
blnMsg = blnMessage
End If
'
strMsg = "Sorry, you cannot Edit/Delete this record, " & vbCrLf & _
"another User is in the process of editing it. " & vbCrLf & vbCrLf & _
"Please try again later."
'
IsLocked = False
Set Rs = frm.RecordsetClone
Rs.Bookmark = frm.Bookmark
Rs.Edit
Exit_IsLocked:
Rs.Close
Set Rs = Nothing
If blnMsg Then
MsgBox strMsg
End If
Exit Function
Error_IsLocked:
Select Case Err.Number
Case 3218
IsLocked = True
Resume Exit_IsLocked
Case Else
MsgBox "Error " & Err.Number & " " & Err.Description
Resume Exit_IsLocked
End Select
End Function
I am still testing, but so far looks good
Regards
Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now -
UK