The data has been changed

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Petrol
    New Member
    • Oct 2016
    • 248

    The data has been changed

    My Form01 allows the user to log on and change their password, by entering a new password twice; if the entries match, the SHA256 hash is created and stored in the AccessAuthority table. The code invoked after the new password is entered, is as follows:
    Code:
    Private Sub txtReenterPassword_AfterUpdate ()
    '
    ' This is called if the user is updating his password and enters this new one a second time
    '
    Dim strHash As String, strNewExpiry As String, Message As String, strSQL As String
    
    On Error GoTo ErrorProc
    
    If txtReenterPassword = SavedPassword Then ' Compare with previous entry
    txtReenterPassword = ".......... .."
    Hide_PwdExpired Messages
    
    ' Update the AccessAuthorisation table with the new hash and expiry date, one year from today.
    strHash = SHA256(SavedPas sword)
    strNewExpiry = Format(DateAdd( "yyyy", 1, Date), "YYYY-MM-DD")
    strSQL = "UPDATE AccessAuthority SET Hash = '" & strHash & "', Expiry = #" & strNewExpiry _
    & "# WHERE PersonID = " & ThisPerson & ";"
    Debug.Print strSQL
    
    CurrentDb.Execute strSQL
    DoEvents ' Without this, I sometimes get an error message "The data has been changed"
    
    ' Display the result on screen, log what has happened, and go
    SavedPassword = "" ' We've finished with this now, get rid of it
    lblNewPwSaved.V isible = True
    txtPwExpiry = strNewExpiry ' Set up the "New pw saved" message.
    txtPwExpiry.Vis ible = True
    cmdDone.Visible = True
    cmdDone.SetFocus
    Call LogActivity("reset " & strHisHer & " password", "")
    ' (LogActivity needs two parameters to prevent it showing 'testdata' or 'livedata')
    Else
    Message = "Passwords don't match"
    MsgBox Message, vbOKOnly, "No match"
    Me!txtEnterNewP assword.SetFocu s
    End If
    
    ByeBye:
    Exit Sub
    
    ErrorProc:
    MsgBox "Error " & Err.Number & " - " & Err.Description , , "Problem updating password"
    Resume ByeBye
    End Sub
    Unfortunately it works only about half the time; the other half it causes the error "Error -2147352567 - The data has been changed".
    I have seen several posts about this on the internet, but none of them have helped me solve the issue. One suggested that if using a SQL server one should set the default value of any bit field to zero. I'm using a striaght Access database as the back end, but tried it anyway - to no avail. The attached document 2147352567.docx contains screenshots of both the error message and the AccessAuthority table design. Inserting Debug.Print statement or STOP statement after the CurrentDb,Execu te statement seemed to help smetimes, but not consistently.
    Are there anyothe things I could try? 2147352567.docx 2147352567.docx 2147352567.docx 2147352567.docx
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32633

    #2
    Much as I hate to be the one who doesn't provide an answer but a work-around instead, I'm going to state - very strongly - that managing your own security within an Access project is just wrong in so many ways. I'm not sure if you were able (or willing even) to attend my recent presentation on this matter for AUG Lunchtime (https://accessusergroup s.org/lunch/event/access-lunchtime-5-2025-05-27/) with Maria Barnes, but there I provide an alternative that makes use of the existing security structure in modern AD domains (and the downloads include an example database with all the necessary code & illustrations of how it's used).

    Because of the dangers involved with rolling your own security I really don't wish to help or encourage anyone to follow that path. Certainly not publicly.

    Comment

    • Petrol
      New Member
      • Oct 2016
      • 248

      #3
      Well, that's a major shock. I have heard nothing of or from AUG for a months, and didn't know how to find their meetings. I did manage to find a link to your lunchtime meeting, but couldn't find a recording of it; the Previous Meetings window didn't take me anywhere helpful..

      I had no idea Windows provided a ready-made secirity facility. and so far haven't been able to find anything about it. I'm sorry I missed your persentation.

      I've spent many months developing the login system for my database and it works pretty well (and avoids the danger you mentioned), so I'm understandably reluctant to throw it all away and start again, but I would be open to investigating the Windows system if I could find it and if it wasn't too much work. But I'm still a pretty basic user, and much of what Maria Barnes et alia were talking about (including your bit on classes) is over my head.

      So now I don't know where to go or how to get there :(.

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32633

        #4
        OK. It was supposed to be made available to all attendees but I couldn't find it even when I logged on so let's go another route.

        If you aren't already a member of the Access Talk Discord server then here's (https://discord.gg/WA6YsCtRej) a link. This is a non-profit resource aimed directly at those interested in Access, set up by Access MVPs, so does not break the rules here. I'm on there much of the time anyway (Logged in & hoverng rather than always active.) so drop a message on there for me (I show there as Ade Bell (NeoPa).) & I'll get the attachment over to you & we can go through the details if you need any help getting it to work.

        I hope to catch up again soon :-)

        Comment

        • Petrol
          New Member
          • Oct 2016
          • 248

          #5
          I'm not having much success here. I did go to the Discord site (strange name ... strange site ... looks as though it was written by and for people about a quarter my age πŸ˜†). Found I had to join, so I did. Found I couldn't send a message to you because it said you weren't a friend. Sent a friend request (about 26 hours ago) but got no response, so I presumably missed some critical step.
          Meantime I googled Active Directory and found pages of stuff all using terminology that not familiar to me, and with links to more pages of similar stuff way above my head - if I have to go that route it will take me months to learn all the basics. So I'm wondering whether to scrap the whole idea of implementinmg security πŸ€”in my project.
          And all, because of a silly little "The data has been changed" :( .

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32633

            #6
            I saw a new account called, simply, Peter (peter_11925). I suspected this was you so I responded, on the server, asking if it was Petrol but have seen no response to that yet. I can confirm there is no pending Friend request so whatever you tried to do seems to have failed.

            I can tell you that the database sample I have available includes all the work done for you, and I will be happy to talk you through the process of implementing it when we manage to get properly connected up.
            Yes. It's complicated. No. You won't need to care about that.

            Discord is certainly a platform set up by & for gamers but that doesn't mean it can't be used by those of us with a few more years on our clocks.

            My biggest problem here is that I keep getting error messages when simply trying to post. My last one was sent numerous times & I eventually had to delete two duplicates as there were three of them there. All before any one of my attempts had been confirmed.

            Comment

            • Petrol
              New Member
              • Oct 2016
              • 248

              #7
              I had a similar problem: The error message staarted "200 ParseError SyntaxError. Json ..." Is this what you were getting?
              I reported it and Niheel has just told me that he has fixed the bug, and asked me to test it. So this post is the test.

              Comment

              • Petrol
                New Member
                • Oct 2016
                • 248

                #8
                Does anybody have any ideas on how to solve the problem reported in the OP above? Essentially the problem is that intermittently (I can't find any pattern) i get an error message with a large negative number, saying "The data has been changed" when doing an SQL UPDATE through VBA (see the line "CurrentDb.Exec ute strSQL" in the OP). Despite the comment that immediately follows that line, the error sometimes occurs even with the DoEvents, or with a one-second pause.

                Comment

                Working...