Handling Runtime Errors

No matter how thoroughly you test and debug your code, runtime errors appear eventually. Runtime errors are errors that occur when Access executes your code. Use the On Error GoTo instruction to control what happens in your application when a runtime error occurs. On Error is not a very sophisticated instruction, but it is your only choice for error processing in Access modules. You can branch to a label or ignore the error. The general syntax of On Error … follows:

						On Error GoTo
						LabelName
						On Error Resume Next
						On Error GoTo 0

On Error GoTo LabelName branches to the portion of your code with the label LabelName:. LabelName must be a label; it cannot be the name of a procedure. The code following LabelName, ...

Get Special Edition Using Access 97, Second Edition 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.