Presentation is loading. Please wait.

Presentation is loading. Please wait.

Error Trapping Part II Runtime Errors Error Handling Conclusion Questions Syntax Errors Error Categories Logic Errors Debugging Tools The Err Object Error.

Similar presentations


Presentation on theme: "Error Trapping Part II Runtime Errors Error Handling Conclusion Questions Syntax Errors Error Categories Logic Errors Debugging Tools The Err Object Error."— Presentation transcript:

1 Error Trapping Part II Runtime Errors Error Handling Conclusion Questions Syntax Errors Error Categories Logic Errors Debugging Tools The Err Object Error Handling & other very practical uses for VBA in MS Access 2000 Part II

2 Error Trapping Part II Runtime Errors Error Handling Conclusion Questions Syntax Errors Error Categories Logic Errors Debugging Tools The Err Object October 11, 2001Error Handling & VBA - Part II2 Error Categories Syntax Errors –Leaving a line of code –Line of code changes color –When VBA compiles code or module Runtime Errors (Synchronous & Asynchronous) –Invoking an Error Handler –Reacting to the Error –Exiting the Error Handler Logic Errors –Improper logic –Code implications –Mistakes

3 Error Trapping Part II Runtime Errors Error Handling Conclusion Questions Syntax Errors Error Categories Logic Errors Debugging Tools The Err Object October 11, 2001Error Handling & VBA - Part II3 Syntax Errors Immediately checks after line of code is entered Forces variable declaration with Option Explicit Info that completes code at insertion point Info about parameters allowed for functions Displays values over cursor only in break mode VBE | Tools | Options

4 Error Trapping Part II Runtime Errors Error Handling Conclusion Questions Syntax Errors Error Categories Logic Errors Debugging Tools The Err Object October 11, 2001Error Handling & VBA - Part II4 Runtime Errors On Error GoTo Error_Handler –Gives the most control for error handling –Causes VBA to jump to that location On Error Resume Next –Allows for VBA to ignore error & continue On Error GoTo 0 –Cancels the error handler –Resets the value of the Err Object

5 Error Trapping Part II Runtime Errors Error Handling Conclusion Questions Syntax Errors Error Categories Logic Errors Debugging Tools The Err Object October 11, 2001Error Handling & VBA - Part II5 Logic Errors Bugs! Me ? Adhere to naming convention Comment your code as much as possible Require variable declaration Fix logic errors as they appear Use the tightest possible scope on variables Avoid variant data type if possible Organize, indent, group & label your code Use sub-procedures and functions Make one change at a time

6 Error Trapping Part II Runtime Errors Error Handling Conclusion Questions Syntax Errors Error Categories Logic Errors Debugging Tools The Err Object October 11, 2001Error Handling & VBA - Part II6 Debugging Tools Breakpoints and single step mode –Set locations where VBA temporarily halts –Single step one line at a time (F8) Immediate window (CTRL G) –Investigate VBA effects directly –Always displays the last 200 lines of output Data Tips work like Tool tips Quick watches on variables (SHIFT F9) MsgBox function

7 Error Trapping Part II Runtime Errors Error Handling Conclusion Questions Syntax Errors Error Categories Logic Errors Debugging Tools The Err Object October 11, 2001Error Handling & VBA - Part II7 The Err Object PropertyExplanation DescriptionReturns a descriptive explanation of the error – description is text string HelpContextReturns a context ID for a topic in an online help file HelpFileReturns a full qualified path to an online help file NumberReturns a numeric value specifying an error. It is Err Object’s default SourceReturns name of application that generated the error in the first place

8 Error Trapping Part II Runtime Errors Error Handling Conclusion Questions Syntax Errors Error Categories Logic Errors Debugging Tools The Err Object October 11, 2001Error Handling & VBA - Part II8 Error Handling Error Handling Flow Diagram

9 Error Trapping Part II Runtime Errors Error Handling Conclusion Questions Syntax Errors Error Categories Logic Errors Debugging Tools The Err Object October 11, 2001Error Handling & VBA - Part II9 Conclusion Errors Happen - Handle them “elegantly” Error must be reproducible every time Structure and comment your code Use naming conventions Organize, indent, group & label your code Modularize your code Use few or no global nor public variables Make one change at a time and test

10 Error Trapping Part II Runtime Errors Error Handling Conclusion Questions Syntax Errors Error Categories Logic Errors Debugging Tools The Err Object October 11, 2001Error Handling & VBA - Part II10 Questions Ofer Shimrat Soundoff Computing (858) 484-0400 ofershimrat@compuserve.com Thank You


Download ppt "Error Trapping Part II Runtime Errors Error Handling Conclusion Questions Syntax Errors Error Categories Logic Errors Debugging Tools The Err Object Error."

Similar presentations


Ads by Google