I have a main form (called frmDR) for data records called delivery receipts with a subform (called sbffrmDRItems) containing the items associated with each delivery receipt # (similar to orders/order line items). I am using pessimistic (edited record) locking. I am trying to indicate to all the users via an unbound label field called lblLockStatus whether the DR currently displayed on their screen is locked, ie, is being edited by another user. I also do not want the locked-out user to be able to edit any of the items for that DR while it is locked.
The key portions of my code to determine if a DR record is locked reside in IsRecordLocked public sub:
Dim rst as DAO.Recordset
On Error Goto HandleErr
Set rst = Forms!frmDR.RecordsetClone
rst.Bookmark = Forms!frmDR.Bookmark
rst.Edit
rst.Update
Forms!frmDR!lblLockStatus.Caption = "NOT LOCKED"
Forms!frmDR!sbffrmDRItems.Form.AllowEdits = True
ExitHere:
rst.Close
Exit sub
HandleErr:
Forms!frmDR!lblLockStatus.Caption = "LOCKED"
Forms!frmDR!sbffrmDRItems.Form.AllowEdits = False
Resume ExitHere
I should mention that frmDR opens based on a query that returns all DR's (only a few thousand records) in descending chronological order. Thus, all users' screens open to the most recent DR on file.
The above code is executed based on frmDR's Current and Timer events and it works but not as I'd like it to. The problem is that each time it executes, the form and subform refresh, which is quite annoying visually. I can not figure out what is causing this to happen?
Is there something wrong with this code/approach? Any suggestions for a better way?
Thanks for any help.
The key portions of my code to determine if a DR record is locked reside in IsRecordLocked public sub:
Dim rst as DAO.Recordset
On Error Goto HandleErr
Set rst = Forms!frmDR.RecordsetClone
rst.Bookmark = Forms!frmDR.Bookmark
rst.Edit
rst.Update
Forms!frmDR!lblLockStatus.Caption = "NOT LOCKED"
Forms!frmDR!sbffrmDRItems.Form.AllowEdits = True
ExitHere:
rst.Close
Exit sub
HandleErr:
Forms!frmDR!lblLockStatus.Caption = "LOCKED"
Forms!frmDR!sbffrmDRItems.Form.AllowEdits = False
Resume ExitHere
I should mention that frmDR opens based on a query that returns all DR's (only a few thousand records) in descending chronological order. Thus, all users' screens open to the most recent DR on file.
The above code is executed based on frmDR's Current and Timer events and it works but not as I'd like it to. The problem is that each time it executes, the form and subform refresh, which is quite annoying visually. I can not figure out what is causing this to happen?
Is there something wrong with this code/approach? Any suggestions for a better way?
Thanks for any help.