在调试模式 Access 97 中避免因错误而停止

Avoid stopping on error when in debug mode Access 97

当我在 Access 97 中进入调试模式时,程序会因任何错误而停止,即使该错误发生在 On Error Resume Next 之后。

我有一个函数可以使用

测试元素key是否在Collection Col
On Error Resume Next
var = Col.Item(key)  'Here the error is raised, and makes debug mode useless
...
InConnection = Not (Err.Number = 5)

这在生产中运行良好,但它使 运行 调试模式下的程序无用。

有没有办法避免程序在调试模式下因某些错误而停止?

据我所知,除了尝试使用上述方法捕获错误外,没有其他方法可以测试 Access 97 中的集合中是否存在键。

在 VBA 编辑器中 Tools | Options... 选项卡 General 激活 Error Trapping 组中的 Break on Unhandled Errors 以关闭 OERN 部分。

要检查 VBA.Collection w/o 错误捕获中的密钥是否存在,需要一个特制的类型库,如 this forum thread.

中讨论的类型库

此外,这样的类型库是练习编写带有 Break on All Errors 集的 VBA 代码艺术的先决条件——这本身就是一个小壮举 :-))