• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 11. Handling Access Error Codes > Error-Checking Sub Routines

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 illustrates the dot (.) identifier operator, working in conjunction with the With statement, accessing the properties of whatever object is being referenced.

With MyControl 
.FontSize = 12 
.ForeColor = 255 
End With 


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint