vba 运行时错误“2501”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4683163/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 11:04:48  来源:igfitidea点击:

Run Time Error '2501'

vbams-accessruntime-error

提问by user574629

I'm having the Run Time Error '2501' on a Form. Does anyone have ideas of why this happens and how to fix it?

我在表单上遇到运行时错误“2501”。有没有人知道为什么会发生这种情况以及如何解决它?

The Report is called through this code:

通过以下代码调用报告:

Private Sub Command92_Click()
    DoCmd.SetWarnings Off
    ''# get current reqid and version number
    DoCmd.OpenQuery "NewReqVersion", acViewNormal

    Dim NewReqID As Integer
    Dim NewVerID As Integer

    NewReqID = Me.Text58
    NewVerID = Me.Version + 1
    [Forms]![UWReviewForm].[StatusID] = 99
    On Error Resume Next
    **DoCmd.Save acForm, "UWReviewForm"**

    DoCmd.OpenForm "NewReqVersionForm", acNormal
    DoCmd.GoToRecord acDataForm, "NewReqVersionForm", acLast
End Sub

Private Sub StatusID_Change()
    Me.LastModifiedTimeStamp = Now()
End Sub

回答by brainwood

The error 2501 can occur on calling OpenForm if there is a problem with the database. Can you please try following the steps in the link below under the headings "Recovering from corruption" and "Symptom: Cannot open a form or report"?

如果数据库有问题,调用 OpenForm 时可能会出现错误 2501。您能否尝试按照以下标题“从损坏中恢复”和“症状:无法打开表单或报告”下的链接中的步骤操作?

MS Access - Recovering from corruption

MS Access - 从损坏中恢复

回答by StockB

In my case, I had a table linked to an external data source, which was another Access database. I had experimented with splitting that database application into its database component and UI component, and had decided to revert the change. Somewhere along the line, this corrupted to the link between my original Access application and the external Access data source. I could verify this by attempting to open the linked table in my original Access application, and it gave an error.

就我而言,我有一个表链接到外部数据源,这是另一个 Access 数据库。我曾尝试将该数据库应用程序拆分为其数据库组件和 UI 组件,并决定恢复更改。沿着这条线的某个地方,这损坏了我原来的 Access 应用程序和外部 Access 数据源之间的链接。我可以通过尝试在我原来的 Access 应用程序中打开链接表来验证这一点,但它给出了一个错误。

My solution was to delete the linked table from my Access application and import it once again. After this, my problem resolved. The forms which could not open before were based on queries which included this external data source.

我的解决方案是从我的 Access 应用程序中删除链接表并再次导入它。在此之后,我的问题解决了。以前无法打开的表单基于包含此外部数据源的查询。