Determining which Errors Occur

The question naturally arises, “How do you know what error has occurred?” Even though Access provides error codes and messages, they are often difficult for users to interpret. If that isn’t enough, they usually don’t have a clue as to what to do about the error. Error handling makes your application more user friendly while giving you more control over what the user encounters.

Suppose you have a table with error codes and their corresponding messages. The following DAO program generates just such a table:

 Sub GenerateErrorTable() Dim db As DAO.Database, rs As DAO.Recordset Dim i As Integer, Msg$ Set db = CurrentDb() Set rs = db.OpenRecordset("ErrorCodes") For i = 1 To 32766 Msg$ = Error$(i) If Msg$ <> "Application-defined ...

Get Access 2002 Programming by Example 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.