我在数据输入表单上收到“运行时错误‘424’:需要对象”

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

此数据输入表单的顶部有一个搜索框,我在表单的 OnCurrent 和 BeforeInsert 事件中包含了一些代码,以对搜索框中发生的情况做出反应。

在 AfterInsert 事件中:

Private Sub Form_AfterInsert()
 
    Records.MoveLast
    TotalRecords = Records.RecordCount
    Exit Sub

End Sub

当我输入新记录并从最后一个字段中跳出选项卡时,我收到运行时 424 错误,在点击调试后,它会将我带到此代码。关于如何解决这个问题有什么建议吗?

我尝试放入错误处理程序,但问题仍然存在。

vba ms-access runtime-error
1个回答
0
投票

使用的是

RecordsetClone

Private Sub Form_AfterInsert()

    Dim Records As DAO.Recordset

    Set Records = Me.RecordsetClone

    Records.MoveLast
    TotalRecords = Records.RecordCount
    Records.Close

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