O'Reilly logo

Access 2002 Programming by Example by Bob Villareal

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required