lemon_balm
Registered User.
- Local time
- Today, 07:59
- Joined
- Feb 7, 2006
- Messages
- 65
Hi,
Can someone please have a look at the below code and see where I'm going wrong.
The code works and I have tested it with message boxes to prove that but the new password isn't being returned to the table.
Option Compare Database
Option Explicit
Dim pwcount As Integer
Private Sub btnchange_Click()
Dim uname As String
Dim opword As String
Dim npword1 As String
Dim npword2 As String
Dim resetpw As String
uname = Me!txtuser.Value
opword = Me!txtoldp.Value
npword1 = Me!txtnewp1.Value
npword2 = Me!txtnewp2.Value
resetpw = DLookup("password", "username", "[userID] ='" & uname & "'")
If opword = DLookup("Password", "username", "[userID] ='" & uname & "'") And npword1 = npword2 Then
resetpw = npword2
Else
MsgBox "Please try again", , "Details Incorrect"
pwcount = pwcount + 1
Me!txtoldp = Null
Me!txtnewp1 = Null
Me!txtnewp2 = Null
End If
If pwcount = 3 Then
MsgBox "please contact the administrator", , "Too many attempts"
DoCmd.Close
End If
End Sub
Table Name: Username
Table fields: Password, UserID, ID
Form Name: Changepassword
Form fields: txtuser, txtoldp, txtnewp1, txtnewp2
Regards
Jason
Can someone please have a look at the below code and see where I'm going wrong.
The code works and I have tested it with message boxes to prove that but the new password isn't being returned to the table.
Option Compare Database
Option Explicit
Dim pwcount As Integer
Private Sub btnchange_Click()
Dim uname As String
Dim opword As String
Dim npword1 As String
Dim npword2 As String
Dim resetpw As String
uname = Me!txtuser.Value
opword = Me!txtoldp.Value
npword1 = Me!txtnewp1.Value
npword2 = Me!txtnewp2.Value
resetpw = DLookup("password", "username", "[userID] ='" & uname & "'")
If opword = DLookup("Password", "username", "[userID] ='" & uname & "'") And npword1 = npword2 Then
resetpw = npword2
Else
MsgBox "Please try again", , "Details Incorrect"
pwcount = pwcount + 1
Me!txtoldp = Null
Me!txtnewp1 = Null
Me!txtnewp2 = Null
End If
If pwcount = 3 Then
MsgBox "please contact the administrator", , "Too many attempts"
DoCmd.Close
End If
End Sub
Table Name: Username
Table fields: Password, UserID, ID
Form Name: Changepassword
Form fields: txtuser, txtoldp, txtnewp1, txtnewp2
Regards
Jason