nick nguyen
11-20-2011, 12:20 PM
Hello everybody!
Could you please show me how to create a password change form for my tblemployees. I have been trying for three days , but I'm still stuck. Thanks a lot for your time.
tblEmployees
lngEmpID strEmpName strEmpPassword strAccess
1 Nick 2 Admin
2 Steve testing2 Manager
3 Brett testing3 Technician
My code:
Private Sub cmdLogin_Click()
Dim PWtocompare As String
'PWtocompare = DLookup("strEmpPassword", "tblEmployees", "strEmpName = Me.cboEmployee.Value")
Me.PrePassword.Value = DLookup("strEmpPassword", "tblEmployees", "[lngEmpID]=" & Me.cboEmployee.Value)
If PrePassword = PWtocompare Then
If NewPassword = ConfirmPassword Then
Me.NewPassword.SetFocus
Dim strSQL As String
strSQL = "UPDATE tblEmployees SET strEmpPassword = '" & Me.NewPassword & "' WHERE ID = lngEmpID"
DoCmd.RunSQL strSQL
Else
MsgBox "Passwords do not match, please re-enter your new password", vbOKOnly, "Passwords do not match"
End If
Else
MsgBox "Current password does not match records. Please enter your current password again", vbOKOnly, "Incorrect Password"
End If
End Sub
Could you please show me how to create a password change form for my tblemployees. I have been trying for three days , but I'm still stuck. Thanks a lot for your time.
tblEmployees
lngEmpID strEmpName strEmpPassword strAccess
1 Nick 2 Admin
2 Steve testing2 Manager
3 Brett testing3 Technician
My code:
Private Sub cmdLogin_Click()
Dim PWtocompare As String
'PWtocompare = DLookup("strEmpPassword", "tblEmployees", "strEmpName = Me.cboEmployee.Value")
Me.PrePassword.Value = DLookup("strEmpPassword", "tblEmployees", "[lngEmpID]=" & Me.cboEmployee.Value)
If PrePassword = PWtocompare Then
If NewPassword = ConfirmPassword Then
Me.NewPassword.SetFocus
Dim strSQL As String
strSQL = "UPDATE tblEmployees SET strEmpPassword = '" & Me.NewPassword & "' WHERE ID = lngEmpID"
DoCmd.RunSQL strSQL
Else
MsgBox "Passwords do not match, please re-enter your new password", vbOKOnly, "Passwords do not match"
End If
Else
MsgBox "Current password does not match records. Please enter your current password again", vbOKOnly, "Incorrect Password"
End If
End Sub