【问题标题】:Struggling to solve MS Access OpenForm was cancelled - error 2501努力解决 MS Access OpenForm 被取消 - 错误 2501
【发布时间】:2017-04-20 03:31:00
【问题描述】:
'Check to see if the recordset actually contains rows
If Not (recordSet.EOF And recordSet.BOF) Then
    recordSet.MoveFirst 'Unnecessary in this case, but still a good habit

    'See if credentials match data
    Do
        If (recordSet!User_ID = PERSAL And recordSet!Password = Password) Then

           'Open Menu form

            DoCmd.OpenForm "Menu", acNormal, "", "", , acNormal

            recordSet.Close 'Close the recordset
            Set recordSet = Nothing 'Clean up

            'Close Login form
            DoCmd.Close acForm, "Login"

            Exit Do
        End If

        recordSet.MoveNext

        If (recordSet.EOF Or recordSet.BOF) Then
            MsgBox "Your credentials are incorrect or you are not registered."

            Exit Do
        End If
    Loop

    'Match the values entered for PERSAL nr. and password fields with a row in User table

Else

    MsgBox "There are no records in the recordset."

     recordSet.Close 'Close the recordset
     Set recordSet = Nothing 'Clean up

End If

Form_Login.txtUser_ID.SetFocus

我已经尝试了过去 2 天找到的所有解决方案,但都无法解决我的错误 2501:

我做到了:

  • 反编译
  • 压缩和修复
  • 处理 MSCOMCTL.OCX 文件
  • 导入新的访问文件

我已经花光了。

对于 MSCOMCTL.OCX 文件,我正在考虑下载 2007 Office 更新 SP 3。

异常/错误出现在这一行:

DoCmd.OpenForm "Menu", acNormal, "", "", , acNormal

【问题讨论】:

  • 检查您的表单打开/加载事件。此外,遍历员工表以查找员工并不是最佳做法。使用 sql 或 dlookups

标签: ms-access vba


【解决方案1】:

您的语法不正确。试试:

DoCmd.OpenForm "Menu", acNormal, , , , acWindowNormal 

【讨论】:

  • 没有变化。
  • 我重新填写了表格。没有区别。
  • 错误再次出现。我今天已经反编译/压缩并修复了两次。
  • 创建一个简单的新表单并让您的代码打开它。如果它没有失败,则错误是您的另一种形式;如果失败,则错误在其他地方。
猜你喜欢
  • 2016-09-09
  • 2018-04-29
  • 2014-01-05
  • 1970-01-01
  • 2010-10-09
  • 2015-01-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多