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:
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
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
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
Comment