Write conflict: I want to always Drop Changes (1 Viewer)

Takunda Mafuta

Registered User.
Local time
Today, 15:41
Joined
Sep 4, 2019
Messages
13
I have a split database and I have duplicated front-end file to make multiple copies for different users. Every-time a change is made on one front-end form, I want the other forms in other front-ends to always drop changes. How can I trap this write conflict to always drop changes maybe through VBA if possible?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 06:41
Joined
May 7, 2009
Messages
19,169
unless the other user requeries his form, he will never notice that the record he is holding has changed.
though, there is a utility to see if the current record you are working is Locked for editing by the another user:
Code:
Public Function acbWhoHasLockedRecord(frm As Form) As Boolean
    ' Display a message box that says either:
    '  -No user has the current record locked, or
    '  -The user & machine name of the user who
    '   who has locked the current record.
    
    Dim rst As DAO.recordSet
    Dim blnMUError As Boolean
    Dim strUser As String
    Dim strMachine As String
    Dim strMsg As String
    
    On Error GoTo HandleErr
    
    ' Default message
    strMsg = "Record is not locked by another user."
    
    ' Clone the form's recordset and synch up to the
    ' form's current record
    Set rst = frm.RecordsetClone
    rst.Bookmark = frm.Bookmark
    
    ' If the current record is locked, then the next
    ' statement should produce an error that we will trap
    rst.Edit
    
ExitHere:
    ' Display either the default message or one specifying
    ' the user and machine who has locked the current record.
    'MsgBox strMsg, , "Locking Status"
    rst.Close
    Set rst = Nothing
    Exit Function
    
HandleErr:
    ' Pass the error to acbGetUserAndMachine which will attempt
    ' to parse out the user and machine from the error message
    If err.Number = 3188 Then
        ' Locked on this machine.
        strMsg = "Some other part of this application " _
         & "on this machine has locked this record."
    Else
        blnMUError = acbGetUserAndMachine(err.description, _
         strUser, strMachine)
        ' If the return value is True, then acbGetUserAndMachine
        ' was able to return the user and machine name of the user.
        ' Otherwise, assume the record was not locked.
        If blnMUError Then
            strMsg = "Record is locked by user: " & strUser & _
             vbCrLf & "on machine: " & strMachine & "."
        End If
    End If
    acbWhoHasLockedRecord = True
    Resume ExitHere
End Function

Public Function acbGetUserAndMachine(ByVal strErrorMsg As String, _
 ByRef strUser As String, ByRef strMachine As String) As Boolean
    ' Parse out the passed error message, returning
    '  -True and the user and machine name
    '   if the record is locked, or
    '  -False if the record is not locked.
    
    Dim intUserPos As Integer
    Dim intMachinePos As Integer
    
    Const USER_STRING As String = " locked by user "
    Const MACHINE_STRING As String = " on machine "
  
    acbGetUserAndMachine = False
    
    On Error Resume Next
    intUserPos = InStr(strErrorMsg, USER_STRING)
    If intUserPos > 0 Then
        intMachinePos = InStr(strErrorMsg, MACHINE_STRING)
        If intMachinePos > 0 Then
            strUser = Mid$(strErrorMsg, _
             intUserPos + Len(USER_STRING), _
             intMachinePos - (intUserPos + Len(USER_STRING) - 1))
            strMachine = Mid$(strErrorMsg, _
             intMachinePos + Len(MACHINE_STRING), _
             (Len(strErrorMsg) - intMachinePos - _
             Len(MACHINE_STRING)))
        End If
        acbGetUserAndMachine = True
    End If
End Function
 

Takunda Mafuta

Registered User.
Local time
Today, 15:41
Joined
Sep 4, 2019
Messages
13
The writes conflict dialog box is still popping up and the answer for all the users is just "Drop Changes". Can there be a code which automates "Drop Changes" so that we don't continually do that manually?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 15:41
Joined
Oct 29, 2018
Messages
21,358
The writes conflict dialog box is still popping up and the answer for all the users is just "Drop Changes". Can there be a code which automates "Drop Changes" so that we don't continually do that manually?
Hi. I'm not sure you'll find a setting for that (if it exists, I don't know where it is). However, my motto is usually to try and avoid a problem rather than react to it. So, maybe we can get to the root of the problem why you're getting write conflicts and see if we could avoid them. For example, why is it a normal practice in your environment to have multiple users updating the same record at the same time but also normal to discard those changes if one of the users happens to finish with their updates first? It just sounds a little bit counter-productive.
 

isladogs

MVP / VIP
Local time
Today, 22:41
Joined
Jan 14, 2017
Messages
18,186
Agree with DBG.
In a well designed database, write conflicts should never occur.
Identify the cause of the problem and then fix that e.g. by changing settings for record locks (though other issues may be responsible)
 

Users who are viewing this thread

Top Bottom