Part IV: Professional Database Development
920
Checking for obvious hardware errors
Whenever possible, you should monitor how much disk space, memory, and other resources are
available to the application. You can avoid many problems encountered by users simply by testing
to confirm that adequate disk space exists. An Access data file can completely fill up a small hard
disk over time, causing the application (and Windows itself) to fail. All the error messages you see
in Figure 26.16 were caused by running out of disk space on the computer.
FIGURE 26.16
Careful planning will help to avoid the unpleasant events that trigger these error messages.
Unfortunately, the VBA language built into Access doesn’t provide functions for checking free disk
space or available memory. You have to resort to Windows API calls to interrogate the system for
this information.
Cross-Reference
Chapter 27 explains how to call Windows API functions from your databases.
Note
You may be wondering why inadequate disk space leads to the memory errors you see in Figure 26.16.
Windows uses disk space as virtual memory when all the physical memory (RAM) on the machine has been
used. Windows creates virtual memory by allocating disk space to use as a swap file to temporarily store things
that otherwise must be stored in memory. Windows continues allocating available disk space until nothing is
left, leading to the “memory” error messages in Figure 26.16. To the application, there is no difference
between running out of physical memory or swap space — a memory error is a memory error, regardless of
the cause.
Maintaining usage logs
Usage logs capture information such as the user’s name or ID, the date, and the time. They provide
valuable information, especially if an error occurs. Although you can easily record too much informa-
tion, a properly designed usage log will permit you to pinpoint whether a certain type of error always
seems to occur when a particular user is working with the system or when a certain query is run.