9.7. Summary

every procedure you write in Access VBA should have error handling. Keep error handling simple and easy to implement, with one basic copy-and-paste code block. Then do a few quick steps if necessary to adapt the error handling to your procedure:

  • Change Exit Function to Exit Sub if the procedure is a sub.

  • Add code to quietly absorb expected errors, if any.

  • Make sure you perform any necessary cleanup if an error occurs.

By following these error-handling guidelines, you'll build VBA code that is easier to debug and maintain, so you can focus on building great features into your application.

Get Access™ 2007 VBA Programmer's Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.