【发布时间】:2017-09-28 15:11:23
【问题描述】:
我的访问表单使用 SHA-256 加密重置存储在数据库中的用户密码。
我收到以下错误。
运行时错误“2585”:
处理表单或报表事件时无法执行此操作。
我在“DoCmd.Close”之前尝试了“DoEvents”功能,但收到了同样的错误。
Private Sub cmdReset_Click()
If (IsNull(Me.txtConfirm) Or IsNull(Me.TxtPassword)) Then
MsgBox "Either the password or confirmation field are empty! Please try again", , ""
Else
If (Me.txtConfirm.Value = Me.TxtPassword) Then
If (Me.txtConfirm = "password" Or Me.TxtPassword = "password") Then
MsgBox "Cannot use 'password' as a password!" & Chr(13) & Chr(13) & "Please try again", , ""
Else
MsgBox "Your password has been reset!", , ""
Call Reset_Password(DLookup("Username", "getCurrentUser"), _
SHA256(Me.txtConfirm, True))
DoCmd.Close
DoCmd.OpenForm "frmLogin"
End If
Else
MsgBox "The passwords you entered do not match!" & Chr(13) & Chr(13) & "Please try again", , ""
End If
End If
End Sub
【问题讨论】:
-
明确指定要关闭的内容
DoCmd.Close acForm, "formName",因为您的代码可以更改实际对象。显示Reset_Password的代码。您可以尝试将关闭命令移到Reset_Password的末尾,但先将其删除并测试代码。