当数量超过大约 90.000 条记录时,在 VBA 中使用 RecordsAffected-method 会导致错误吗?

发布于 2024-10-19 21:07:24 字数 770 浏览 3 评论 0原文

我正在 VBA(MS Access 内部)中运行追加查询,如下所示。 当我在 VBA 中使用 RecordsAffected 方法来跟踪已插入的记录数时,当数量超过大约 90.000 条记录及以上时,会导致错误吗? (它说某种 stackoverflow 错误)

有趣的是,当我不使用 RecordsAffected-method 时,查询工作得很好。当受影响的行数低于 90.000 时,它也可以正常工作。

有什么问题吗?这是 VBA 中的错误吗?
.

Dim dbs As DAO.Database  
sql As String  
iCount As Integer  
Set dbs = CurrentDb  

sql = "INSERT INTO " & ReceiveTable_selected & " SELECT " & NavisionTable_selected & ".* " & _
                   "FROM " & NavisionTable_selected & " " & _
                   "WHERE ((([" & NavisionTable_selected & "].[Entry No_]  ) >" &   
                    Counter_selected & "))"


dbs.Execute sql, dbFailOnError
iCount = dbs.RecordsAffected

I'm running an append-query in VBA (inside MS Access) that looks like the code below.
When I use the RecordsAffected-method in VBA in order to keep track of how many records that have been inserted, it causes an error when the number exceeds approximately 90.000 records and above? (some kind of stackoverflow error it says)

The funny part is, that when I don't use RecordsAffected-method, the query works just fine. And it also works fine when the number of rows affected is below 90.000.

What can be wrong? Is this a bug in VBA?
.
.

Dim dbs As DAO.Database  
sql As String  
iCount As Integer  
Set dbs = CurrentDb  

sql = "INSERT INTO " & ReceiveTable_selected & " SELECT " & NavisionTable_selected & ".* " & _
                   "FROM " & NavisionTable_selected & " " & _
                   "WHERE ((([" & NavisionTable_selected & "].[Entry No_]  ) >" &   
                    Counter_selected & "))"


dbs.Execute sql, dbFailOnError
iCount = dbs.RecordsAffected

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

豆芽 2024-10-26 21:07:24

Dim iCount As Integer 更改为 Dim iCount As Long

从帮助文件中:

整数变量存储为 16 位(2 字节)数字,范围为
值从 -32,768 到 32,767。

和:

长(长整数)变量是
存储为有符号 32 位(4 字节)
数值范围为
-2,147,483,648 至 2,147,483,647。

Change Dim iCount As Integer to Dim iCount As Long

From the help file:

Integer variables are stored as 16-bit (2-byte) numbers ranging in
value from -32,768 to 32,767.

and:

Long (long integer) variables are
stored as signed 32-bit (4-byte)
numbers ranging in value from
-2,147,483,648 to 2,147,483,647.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文