jmark@stayintouch.us
Member
- Local time
- Today, 14:56
- Joined
- Apr 25, 2019
- Messages
- 62
I have the code below that is supposed to check if a record is locked by any other user, and if so, pop up a warning message. The oncurrent event runs this single line: DisplayLockStatus. It seems to work fine when User1 is in a record and User2 tries to view that same record, but the problem is that every time any user opens the form, it pops up the message even if no one else has access open at all. Split DB. I temporarily put a msgbox to pop up the error code and it is showing 91 on load. Any help is appreciated!
The code for the sub is:
Private Sub DisplayLockStatus()
Dim frm As Form
Dim rst As DAO.Recordset
On Error Resume Next
' We clone the form recordset and sync up to the form current record using the bookmark
Set rst = frm.RecordsetClone
rst.Bookmark = frm.Bookmark
' If the current record is locked, then editing the recordset will produce an error that we will trap
rst.Edit
If Err.Number <> 0 Then
MsgBox ("WARNING! This record is currently being edited by another user and is locked. To make any changes to this record you will need to have exclusive access!")
End If
rst.Close
End Sub
The code for the sub is:
Private Sub DisplayLockStatus()
Dim frm As Form
Dim rst As DAO.Recordset
On Error Resume Next
' We clone the form recordset and sync up to the form current record using the bookmark
Set rst = frm.RecordsetClone
rst.Bookmark = frm.Bookmark
' If the current record is locked, then editing the recordset will produce an error that we will trap
rst.Edit
If Err.Number <> 0 Then
MsgBox ("WARNING! This record is currently being edited by another user and is locked. To make any changes to this record you will need to have exclusive access!")
End If
rst.Close
End Sub