Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display Message to a Blocked Record

Status
Not open for further replies.

RADM

Programmer
Dec 27, 2003
36
0
0
IT
Hi,

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.

Regards,

RADM
 
Hi

I am trying to do same

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 - UK
 
Hi,

Of course Ken. Thank you very much. Hope we'll contact each other soon.

Regards,

RADM
 
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
 
Hi Again

Seems to work OK, but I have the If BlnMsg... in wrong place should be in the Error trap part of the code after IsLocked = True

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top