苦苦挣扎解决MS Access OpenForm被取消 - 错误2501

时间:2017-04-19 12:08:47

标签: ms-access access-vba

'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

1 个答案:

答案 0 :(得分:0)

您的语法不正确。尝试:

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