819
CHAPTER
Handling Errors and
Exceptions
IN THIS CHAPTER
Addressing logical and runtime
errors
Identifying which errors to trap
Using VBA code to trap errors
A
ccess database applications prepared by even the very best develop-
ers have problems. By their very nature — when you consider table
and query design, forms and reports, and implementation details —
database applications are complicated. Plus, the VBA code written for data-
bases often results in coding errors. If you’re lucky, the problem and its
cause are obvious and easy to fix. If you’re not so lucky, you know there’s a
problem, but its source isn’t immediately apparent. In the worst-case sce-
nario, programming bugs are silently and perniciously damaging data — or
the representation of data in an application — without any warning.
This chapter looks at the types of errors you’ll encounter in Access applica-
tions and tells you the steps you can take to uncover and repair these
critters.
Note
This chapter largely ignores the errors caused by poor design — those that
misrepresent data because of ill-designed queries, update and insert anomalies
caused by inappropriate use of referential integrity rules, and so on. For the
most part, the causes of design errors are rooted in failure to conform to data-
base development best practices, misunderstanding Access query design, and
other causes. You have to pay careful attention to database design principles
in order to produce truly robust Access applications.
Note
There is no database for this chapter because the chapter contains only fairly
simple VBA code examples.