I've a form with Edited Record as Record Locking property. Now I want to display a message to the user if he is in a record which is blocked by another user. The form is bound to a query.
I have found a Microsoft KB Article which shows you how to enable buttons based upon this, but still I cannot see how to detect is actually locked, KB article seems to depend on fact if record is not locked then user can amend, thus setting .dirty property
KB article is KB122294
I will let you know if I make any progress, would you do like wise please?
Regards
Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now -
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 -
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.