VBA Access: Resolved Runtime Errors

While I am developing my MS Access application, I open it with a slide. If an error occurs that is not trapped (with ON ERROR ...), an error message box appears. It's good.

When a user opens my application, he does not change the click and the corresponding start form opens. However, now unresolved errors are not displayed, the application behaves as if the user pressed the "Stop" button in the message box. I don't want this behavior.

Is there a parameter / property / variable that provides the same behavior in production code (preferably even when the app id is converted to mde) as in the development case, i.e. displays a message box for every pending error? Or is it necessary to trap errors in each individual event procedure and pop-up message box for the program?

0


source to share


3 answers


It turns out that this is a side effect of setting the AllowSpecialKeys property to False. It can be done programmatically, but I did it from the menu under Tools> Start.

Since this property allows the user to open the code editor, it makes sense, but the relationship of the phenomenon described with this option was mysterious to me.



Does this mean that if I want to hide my code, I have to write all these error handlers? Or is there one central place (like the main method in Java) where I can call the error handler. Alternatively, can I allow special keys and just protect the code with a keyword?

+1


source


You can create your own error handler and add it to all procs, subs and functions. You've got this very nice MZ Tools VBA Extension that allows you a lot, like adding line numbers to your code, "pre-programming" your error shortcut, etc.

If you're smart enough, you should be able to use this add-on to create standard "error management" code that displays things like err.number, err.description, and an invalid erl value, which is the line number where the error occurred (you must first number your lines before you can get that value).



EDIT: I just opened this question on a similar topic.

0


source


As mentioned, MZ-Tools 3.0 is a great tool for quickly adding error handlers. Also remember that errors that occur in procedures without error handlers bubble up until the last On Error statement issued. (And if no assertion exists, you end up with a little gray debug block.) The net effect of this is that you can do minimal error handling by simply adding error handlers to only those procedures that are Public (or Friend) or triggered by an event ... This ensures that you always use a "top-level" error handler. If you would like to add special treatment to your private routines afterwards, feel free to. If not, they will bubble up to the top-level error handler when an error occurs.

0


source







All Articles