Results 1 to 4 of 4
  1. #1
    jaryszek is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2016
    Posts
    565

    This record has been changed by another user since you started editing it

    Hi,

    My split database is working on One Access for Developer (me) and Access runtime for users.

    Problem is described here:



    https://support.microsoft.com/en-us/...ted-editing-it

    My code is working like that:

    Code:
    Private Sub Button_Run_Click()
    
    Dim LoginName As String
    Dim strSQL As String
    Dim LookLast As String
    Dim Digits As Long
    Dim NewOne As String
    Dim response As String
    Dim SqlString As String
    Dim ActualYear As String
    Dim DokumentName As String
    Dim i As Byte
    Dim counter As Byte
    Dim Obowiazek As String
    Dim BoolListbox As Boolean
    Dim rstBraki As Recordset
    
    
    DoCmd.SetWarnings False
    
    
    LoginName = TempVars("Username")
    
    
    Me.Requery
    
    
    On Error Resume Next
        LookLast = DLast("[Numer_zgłoszenia]", "Qry_Numbers", "[Login] ='" & LoginName & "'")
    If Err.Number <> 0 Then
            NewOne = LoginName & "_" & Year(Date) & "_1"
        Else
            NewOne = GetDigits(LookLast)
    End If
    On Error GoTo 0
    
    
    For i = 0 To ListBox_Doc.ListCount
    
    
        If ListBox_Doc.Selected(i) = True Then
        counter = counter + 1
    
    
            DokumentName = ListBox_Doc.Column(0, i)
            Obowiazek = ListBox_Doc.Column(1, i)
            
            If Obowiazek = "TAK" Then
                BoolListbox = True
            Else
                BoolListbox = False
            End If
            
            
            SqlString = "INSERT INTO tbl_Braki([Numer_zgłoszenia], [Zleceniodawca_nr], [Zleceniodawca_nazwa], [Nr_SAP], [Imię_i_Nazwisko], [Dokument], [Czy_obowiązkowy], [Data_Wysłania], [Data_Zwrotu], [Uwagi], [Login]) " & _
                        "VALUES ('" & NewOne & "', '" & Combo_Spolka.Column(1) & "', '" & Combo_Spolka.Column(0) & "', '" & Nr_SAP.Value & "', '" & Imię_i_Nazwisko.Value & "', '" & DokumentName & "', " & BoolListbox & ", '" & Data_Wysłania.Value & "', '" & Data_Zwrotu.Value & "', '" & Uwagi.Value & "', '" & LoginName & "');"
    
    
            DoCmd.RunSQL SqlString
            
            ListBox_Doc.Selected(i) = False
            
        End If
    
    
    
    
    Next i
    
    
    If counter = 0 Then
        MsgBox "nie wybrano żadnego dokumentu, rekord NIE został dodany"
    End If
    
    
    '''rstBraki.Update
    
    
    Application.Echo True
    
    
    
    
    End Sub
    I have listbox with 25 documents where user can choose multiple documents per each Client. This code is inserting this documents for number of documents choosen by user.

    So If user checks Document 1 , Document 2 and Document 3 on listbox this code will add 3 new records into main table.

    Problem is where two users are trying to run macro from front -end at the same time. The problem: "This record has been changed by another user since you started editing it" is occuring...

    I have tried to use:

    Code:
    DoCmd.GoToRecord , , acNewRec
    and

    Code:
    ''Set rstBraki = CurrentDb.OpenRecordset("tbl_Braki")
    rstBraki.AddNew
    
    ''code here
    
    rstBraki.update
    but these methods failed...
    How can I avoid this error using code?
    Maybe when error is occurning by second user the macro will loop for 2 secunds to avoid it?

    It is very serious problem for my database,
    please help
    Jacek Antek

  2. #2
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Good explanation!

  3. #3
    jaryszek is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2016
    Posts
    565
    Thank you aytee111,

    I have fixed it.

    The code here:

    Code:
    Me.Requery
    was causing that. If one user was running macro, second had an error because of requering the same form which was used by another user at the same time.

    My solution for this is adding insted above code:

    Code:
    docmd.openquery "your queyname"
    docmd.close acquery, "your queyname"
    Best Wishes,
    Jacek Antek

  4. #4
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Well done! Sorry we couldn't help.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Time/User Stamp for Changed Record
    By dweekley in forum Access
    Replies: 2
    Last Post: 04-25-2017, 06:39 AM
  2. Replies: 6
    Last Post: 07-31-2015, 12:03 PM
  3. Replies: 2
    Last Post: 02-07-2015, 11:20 PM
  4. Replies: 6
    Last Post: 09-13-2011, 01:52 PM
  5. Replies: 5
    Last Post: 08-26-2011, 04:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums - Senior Forums