【问题标题】:Error 2585 on Close Form: action can't be carried out while processing a form or report event关闭表单上的错误 2585:处理表单或报告事件时无法执行操作
【发布时间】: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 的末尾,但先将其删除并测试代码。

标签: forms ms-access vba


【解决方案1】:

尝试颠倒这些命令:

DoCmd.Close
DoCmd.OpenForm "frmLogin"

或将最后一个命令移至表单的Unload事件。

【讨论】:

  • 所以我刚刚尝试删除 DoCmd.OpenForm "frmLogin" 我也尝试交换两者的顺序,但我仍然收到该行的错误...我创建的函数在运行 SQL 脚本之前,这可能是问题吗?也许没有足够的时间来完成 SQL 脚本?
  • 好了,去掉函数的调用,你就知道了。
猜你喜欢
  • 2021-06-21
  • 2018-05-19
  • 1970-01-01
  • 2011-08-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-12-28
  • 1970-01-01
相关资源
最近更新 更多