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

Chapter 16. Debugging: Your Key to Succe... > Looking At Gotchas with the Debug Wi...

Looking At Gotchas with the Debug Window

Although the Access debugger is excellent, the debugging process itself is wrought with an array of potential problems:

  • The debugging process can interrupt code execution, especially when forms are involved. When this occurs, the best bet is to place Debug.Print statements in your code and examine what happens after the code executes.

  • Along the lines of the previous problem, it is difficult to debug code where GotFocus and LostFocus events are coded. Moving to the Debug window triggers the LostFocus event. Returning to the form causes the GotFocus event to be triggered. Once again, a great solution is Debug.Print. You also might consider writing information to an error log for perusal after the code executes.

  • Code that uses Screen.ActiveForm and Screen.ActiveControl wreaks havoc on the debugging process. When the Debug window is active, there is no active form and no active control. Avoiding these lines in your code wherever possible alleviates this problem.

  • Finally, be aware that resetting code can cause problems. If you are modifying environmental settings, you are left with whatever environmental settings your application code changed. If you continue execution after the error without resetting, all sorts of other problems can occur. It is a good idea to code a special utility routine that resets your environment.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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