关闭表单上的错误2585:处理表单或报表事件时无法执行操作

问题描述 投票:1回答:1

My Access表单使用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
forms ms-access access-vba
1个回答
1
投票

尝试颠倒这些命令:

DoCmd.Close
DoCmd.OpenForm "frmLogin"

或将最后一个命令移动到窗体的Unload事件。

© www.soinside.com 2019 - 2024. All rights reserved.