9.9. Summary

Every procedure you write in Access VBA should have error handling. As we've shown in this chapter, to keep error handling simple and easy to implement, you can copy and paste the code shown previously in Basic Error Handling with a Twist. 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 2003 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.