First of all, this is my first post so I am hoping not to screw it up too bad. I am working on setting up a simple login for an access database. The database is retained on a secure internal server, the login is just to help keep other employees from tampering with the data in the database. Through research and testing it out, I was able to get it working. However, when it processes the password change, a prompt appears to re-type in the username. I have a function setup (UserNameWindow s) to get the Windows Username of the employee and am using that as their login ID. My question is, is there something wrong with my SQL statement causing it to verify; or am I simply missing something? My assumption is my 'WHERE' section of the SQL statement is incomplete or incorrect.
Code:
Private Sub Command0_Click()
Dim strSQL As String
strSQL = "UPDATE tblUser SET Password = '" & Me.txtNewPW.Value & "' WHERE [UserName] = " & Me.txtLoginID.Value
If IsNull(Me.txtLoginID.Value) Then
MsgBox "Please enter LoginID", vbInformation, "LoginID Required"
Me.txtLoginID.SetFocus
ElseIf IsNull(Me.txtOldPassword.Value) Then
MsgBox "Please enter password", vbInformation, "Password Required"
Me.txtOldPassword.SetFocus
Else
If (IsNull(DLookup("[UserName]", "tblUser", "[UserName] ='" & UserNameWindows & "' And password = '" & Me.txtOldPassword.Value & "'"))) Then
MsgBox "Old password incorrect", vbOKOnly, "INCORRECT PASSWORD"
Else
If IsNull(Me.txtNewPW.Value) Then
MsgBox "Please enter a new password", vbOKOnly, "New Password"
Else
If IsNull(Me.txtNewPW2.Value) Then
MsgBox "Please confirm your new password", vbOKOnly, "Confirm New Password"
Else
If Me.txtNewPW.Value = Me.txtOldPassword.Value Then
MsgBox "New Password Cannot Be The Same As Old Password", vbCritical, "Password Violation"
Else
If Me.txtNewPW.Value <> Me.txtNewPW2.Value Then
MsgBox "New passwords does not match", vbOKOnly, "Verify New Password"
Else
If Me.txtNewPW.Value = Me.txtNewPW2.Value Then
Me.txtLoginID.SetFocus
DoCmd.RunSQL strSQL
MsgBox "Password Change Successful!", vbOKOnly, "Password Changed"
DoCmd.Close
DoCmd.OpenForm "Login"
End If
End If
End If
End If
End If
End If
End If
End Sub
Comment