Fixing Errors After Trapping Them

The preceding example handled the error by invoking a MsgBox with additional information. That is one option, but in certain cases, it might be possible to actually fix the error that is causing the problem—especially if it is impossible to code around the problem. The following code handles the error by creating the missing table that caused the error:

 Private Sub Command18_Click() Dim td As TableDef, fld As Field, test As String Dim db As Database, rs As Recordset, ws As Workspace DoCmd.SetWarnings (False) DoCmd.RunSQL "Delete NonCurrent.[Table Name] " & _ "FROM NonCurrent;" DoCmd.SetWarnings (True) ' This program creates a Table of Tables in your database Set ws = CreateWorkspace("JetWorkspace", "admin", ...

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.