Error-Checking Sub Routines

A few things about this program need to be brought to your attention. The first thing to notice is the On Error Goto [Label] statement. This executes only if there is an error, but in this case, an error is intentionally triggered, as the comment indicates. Notice that the statement directs the program to the ErrorHandler label, where the error is handled by finding the error properties for the MsgBox. The second thing to notice is that the For..Each construct, which has been covered, loops through the Errors collection, which in this case only has one error, to find the error. The With statement, nested within the For..Each loop, is a great way to examine, read, or change object properties. The following example ...

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.