Lorenz Meyer
Lorenz Meyer

Reputation: 19895

Avoid stopping on error when in debug mode Access 97

When I enter into debug mode in Access 97, the program will halt on any error, even if that error is occurring after On Error Resume Next.

I have a function that tests if an element key is in a Collection Col using

On Error Resume Next
var = Col.Item(key)  'Here the error is raised, and makes debug mode useless
...
InConnection = Not (Err.Number = 5)

This works well in production, but it makes running the program in debug mode useless.

Is there a way to avoid that the program halts on certain errors in debug mode ?

As far as I could search there is no way to test if a key exist in a collection in Access 97, other than try and catch the error using the above method.

Upvotes: 0

Views: 81

Answers (1)

wqw
wqw

Reputation: 11991

In VBA editor Tools | Options... on tab General activate Break on Unhandled Errors in Error Trapping group to silence OERN sections.

To check key existence in a VBA.Collection w/o error trapping one would need a specially crafted typelib, like the one discussed in this forum thread.

Moreover, such typelib is a prerequisite for practicing the art of writing VBA code with Break on All Errors set -- a small feat in itself :-))

Upvotes: 1

Related Questions