MS-Access VBA: form_error vs on error
I am trying to set up error handling for a MS-Access application. The standard method to do this seems to be with an On Error statement in each subroutine/function. It seems simpler to me to use the Form_Error function to catch all the runtime errors in that form as opposed to an On Error statement for each sub/function called by an event on that form. (Obviously, for code in modules, there is no Form_Error function and therefore the only method is the On Error statement)
What are the pros and开发者_JS百科 cons of using On Error vs Form_Error?
The Form.Error event is limited. From Access help:
"This includes Microsoft Access database engine errors, but not run-time errors in Visual Basic or errors from ADO."
The free MZTools utility can, with the click of a button, put in error handling code in each event procedure for you. You can also easily customize the code for your own preferences. The utility also has many more useful features such as an improved find functionality and easily locating called procedures.
精彩评论