When you're creating applications in the real world, it's important to make them the most robust systems possible. To do so, you must start when the application is first loading.
It's highly recommended that you perform startup checking at various levels, especially regarding the back-end database and the connections into it. Many problems can occur for which you can provide a way to resolve automatically or at least have the system back users out gracefully. Some problems that can occur, and for which no simple programming solution exists, happen when Windows causes an application error or when the front-end database is corrupt.
If Windows causes an application error (commonly referred to as a General Protection Fault), Windows 9x/NT usually displays a polite message box and returns you to the main desktop (see Figure 26.1). No more having to shut down Windows and restart the machine!
If the front end becomes corrupted, the user or administrator must repair the database. To do so from Access, follow these steps:
1. |
Open Microsoft Access without specifying a database. |
2. |
Click Cancel in the Open Database dialog. |
3. |
From the Tools menu, choose Database Utilities and then Repair Database. |
4. |
In the Compact and Repair Database dialog, find the front-end .mdb file to repair and click Compare. |
With the back end, it's important to trap all situations that can come up. This chapter can't cover every situation, but it provides solutions to some of the major ones. First, however, look at the routine that does the startup checking, in Listing 26.1. The code is broken up with comments, and each code segment is explained throughout the rest of this chapter. The function listed is ap_AppInit(), found in the modGlobalUtilities module in the VideoApp.mdb database, on the accompanying CD-ROM in the Examples folder.
The first section in Listing 26.1 stores the following:
The front-end path to the variable pstrAppPath
The back-end name to pstrBackEndName
The last good back-end path to pstrBackEndPath
ap_AppInit()performs these tasks by storing and retrieving the values from properties on the database itself.
18.227.72.212