Office中国论坛/Access中国论坛
标题:
[窗体] 谁能帮我完成“修改密码”窗体的代码
[打印本页]
作者:
2818110
时间:
2011-2-11 10:59
标题:
[窗体] 谁能帮我完成“修改密码”窗体的代码
请各位大虾指教,小弟感激不尽
作者:
2818110
时间:
2011-2-11 11:01
刚才忘了传附件,不好意思
作者:
roych
时间:
2011-2-11 11:58
建议转为2003版本,以便更多的网友帮忙解决问题。
我这里只能给一段代码你试试看:
Private Sub Cmd_Submit_Click()
DoCmd.SetWarnings False
'说明:T_User为用户表,pwd为表中密码字段,Me.Txt_User为窗体用户文本框,Me.Txt_oldPwd为旧密码文本框
If DLookup("pwd", "T_User", "[Login User]='" & Me.Txt_User & "'") <> Me.Txt_oldPwd Or IsNull(Me.Txt_oldPwd) Then
MsgBox "旧密码错误", vbCritical, "出错"
Me.Txt_User.SetFocus
'Me.Txt_NewPwd为新密码文本框,Me.Txt_CfmPwd为确认密码文本框
ElseIf IsNull(Me.Txt_NewPwd) Or IsNull(Me.Txt_CfmPwd) Then
MsgBox "请输入新密码", vbInformation, "出错"
Me.Txt_NewPwd.SetFocus
ElseIf Me.Txt_NewPwd.Value <> Me.Txt_CfmPwd.Value Then
MsgBox "确认密码和新密码不一致", vbCritical, "出错"
Me.Txt_CfmPwd = ""
Me.Txt_NewPwd = ""
Me.Txt_NewPwd.SetFocus
Else
'全部对得上之后进行更新查询。
SSql = "UPDATE T_User SET T_User.Pwd = '" & Me.Txt_NewPwd.Value & "' WHERE ( T_User.[Login User] = '" & Me.Txt_User.Value & "')"
DoCmd.RunSQL (SSql)
If MsgBox("已成功更改密码" & Chr(13) & Chr(13) & "新密码为:" & Me.Txt_NewPwd & Chr(13) & Chr(13) & "请记住新密码", vbInformation + vbOKOnly, "成功更新密码") = vbOK Then
‘关闭更改密码的窗体。
DoCmd.Close acForm, "frm_ChgPwd", acSaveYes
End If
End If
End Sub
复制代码
欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/)
Powered by Discuz! X3.3