How to create a message box for edited record locks?

omarrr128

Member
Local time
Today, 11:34
Joined
Feb 5, 2023
Messages
72
I have set the Form Record lock type to "Edited Records" only. When a user tries to edit a record which is locked by another user they will hear a Windows error ding sound but I want a message box to pop up too. I have tried searching it up and even asking Chat GPT to create some code but nothing seems to work. I feel like there has to be something to make a message box come up for this.

Anyone know how?

Thank you
 
Chat GPT to create some code but nothing seems to work.
if it does, then we are doomed. T-800 will come and terminate us all.
 
A very lean approach:
Code:
Private Sub Form_Current()
    If IsRecordLocked Then MsgBox "Record locked"
End Sub

Private Function IsRecordLocked() As Boolean
    On Error Resume Next
    With Me.Recordset
        .Edit
        .Fields("ValueX") = .Fields("ValueX")
        .Update
    End With
    If Err.Number > 0 Then IsRecordLocked = True
    On Error GoTo 0
End Function
ValueX here is a simple field in the record, not exactly a key.
With the attempt to overwrite the field with the own content, it is tested for errors.
 
ValueX here is a simple field in the record, not exactly a key.
possible...
but will always dirty the form.
not advisable when the back end is not access and much traffic is going on.
 

Users who are viewing this thread

Back
Top Bottom