ms应用程序FE中的密码更改 [英] Password Change in ms application FE
问题描述
我在创建用于我的用户在我的ms Access 2016开发的应用程序中更改自己密码的代码时遇到问题,请参阅以下内容:
问题在于此代码以粗体显示,而不是更新员工表上的密码。
src =" UPDATE tblStaff SET EmpPassword ='Me.txtStaffPasswords'"
src = src& " WHERE(((EmpName)='Me.CboEmpName'))"
CurrentDb.Execute src
期权比较数据库
期权显式
私有子CmdChgPW_Click()
Dim src As String
如果IsNull(Me.txtNewPW1)或IsNull(Me.txtNewPW2)则为
MsgBox"请输入新密码",vbInformation,"需要新密码"
Me.txtNewPW1 =""
Me.txtNewPW2 =""
$
退出子目录
否则
如果Me.txtNewPW1<> Me.txtNewPW2然后是
MsgBox"密码不匹配",vbInformation," MissMatch"
Me.txtNewPW1 =""
Me.txtNewPW2 =""
Me.txtNewPW2.SetFocus
退出Sub¥
结束如果
结束如果
src =" UPDATE tblStaff SET EmpPassword ='Me.txtStaffPasswords'"
$
src = src& "WHERE(((EmpName)='Me.CboEmpName'))" b $ b CurrentDb.Execute src
MsgBox" Change password successful",vbInformation,"更改密码"
$
DoCmd.Close
结束子
$
私人子公司CmdChgPWProceed_Click()
Dim sMyStaffId As String
如果IsNull(Me.CboEmpName)则为$
MsgBox"请输入登录名",vbInformation,"登录所需"
Me.CboEmpName.SetFocus
txtNewPW1.Visible = False
txtNewPW2.Visible = False
ElseIf IsNull(Me.txtStaffPasswords )然后
MsgBox"请输入密码",vbInformation,"需要密码"
Me.txtStaffPasswords.SetFocus
txtNewPW1.Visible = False
txtNewPW2.Visible = False
否则
如果Me.txtStaffPasswords.Value = DLookup("EmpPassword","tblStaff", " [StaffID] ="& Me.CboEmpName.Value)然后
sMyStaffId = Me.CboEmpName.Value
MsgBox"登录和密码正确,继续更改密码",vbInformation,"登录成功"
$
CboEmpName.Visible = False
txtStaffPasswords.Visible = False
txtNewPW1.Visible = True
txtNewPW2.Visible = True
否则
MsgBox"登录或密码不正确,联系管理员",vb信息,"登录失败"
txtNewPW1.Visible = False
txtNewPW2.Visible = False
结束如果
结束如果
结束子
员工表包含以下字段:
StaffId(PK)
EmpName(短文本)
EmpPassword(短文)
表单包含以下字段:
- CboEmpName
- txtStaffPasswords
- txtNewPW1
- txNewPW2
问候
Chris
由于没有一行以粗体字母,没有人能够&NBSP;告诉哪一行则是问有关。此外,当您单步执行代码时,是否有错误消息?如果是这样,它会说什么?
I have a problem to create a code to be used for my user to change their own password in my ms Access 2016 developed application see below:
The problem is on this code in bold below it is not updating the password on the staff table.
src = " UPDATE tblStaff SET EmpPassword = 'Me.txtStaffPasswords' "
src = src & "WHERE (((EmpName)='Me.CboEmpName'))"
CurrentDb.Execute src
Option Explicit
Private Sub CmdChgPW_Click()
Dim src As String
If IsNull(Me.txtNewPW1) Or IsNull(Me.txtNewPW2) Then
MsgBox "Please enter new password", vbInformation, "New password Required"
Me.txtNewPW1 = ""
Me.txtNewPW2 = ""
Exit Sub
Else
If Me.txtNewPW1 <> Me.txtNewPW2 Then
MsgBox "Passwords do not match", vbInformation, "MissMatch"
Me.txtNewPW1 = ""
Me.txtNewPW2 = ""
Me.txtNewPW2.SetFocus
Exit Sub
End If
End If
src = " UPDATE tblStaff SET EmpPassword = 'Me.txtStaffPasswords' "
src = src & "WHERE (((EmpName)='Me.CboEmpName'))"
CurrentDb.Execute src
MsgBox "Change password successful", vbInformation, "Change Password"
DoCmd.Close
End Sub
Private Sub CmdChgPWProceed_Click()
Dim sMyStaffId As String
If IsNull(Me.CboEmpName) Then
MsgBox "Please enter login", vbInformation, "Log in required"
Me.CboEmpName.SetFocus
txtNewPW1.Visible = False
txtNewPW2.Visible = False
ElseIf IsNull(Me.txtStaffPasswords) Then
MsgBox "Please enter password", vbInformation, "Password required"
Me.txtStaffPasswords.SetFocus
txtNewPW1.Visible = False
txtNewPW2.Visible = False
Else
If Me.txtStaffPasswords.Value = DLookup("EmpPassword", "tblStaff", "[StaffID]=" & Me.CboEmpName.Value) Then
sMyStaffId = Me.CboEmpName.Value
MsgBox "Login and Password correct, proceed to change password", vbInformation, "Login successful"
CboEmpName.Visible = False
txtStaffPasswords.Visible = False
txtNewPW1.Visible = True
txtNewPW2.Visible = True
Else
MsgBox "Incorrect Login or Password, contact Admin", vbInformation, "Login failure"
txtNewPW1.Visible = False
txtNewPW2.Visible = False
End If
End If
End Sub
The staff table has the following fields:
StaffId (PK)
EmpName (Short Text)
EmpPassword (Short Text)
The form has the following fields:
- CboEmpName
- txtStaffPasswords
- txtNewPW1
- txNewPW2
Regards
Chris
Since none of the lines are in Bold lettering, no one can tell which line you are asking about. Also, when you step through the code, is there an error message? If so, what does it say?
这篇关于ms应用程序FE中的密码更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!