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.

0 0

Post a comment