Share this Page URL

Chapter 5. Using Visual Basic to Automat... > Handling Errors and Debugging Code - Pg. 177

Using Visual Basic to Automate Your Database 177 12. 13. 14. 15. Select the variable strFilePath, and then click Debug, Add Watch to add this variable to the lists of watches. Click OK in the Add Watch dialog box. Select varForm.Name in the first Debug.Print statement, and add this expression as well. When strFilePath and varForm.Name are added to the Watches window, notice that their values are listed as Out of Context at this point. On the View menu, click Immediate Window. As we step through this procedure, we'll see how each statement is output. On the Debug toolbar, click Step Into. As soon as you step into the first line of the procedure, the value of strFilePath changes to an empty string, signified by the pair of closed quotation marks in the Watches window, and varForm.Name's value is listed as Object Required. Keep clicking Step Into. When you come to the Debug.Print statement, the Watches window shows the value of var- Form.Name as Import. As you continue to click the button, you can see in the Immediate window that the variable's value changes as the For Each...Next statement outputs the name of each form in the database. As you step through the rest of the procedure, the value of strFilePath will be displayed in the Immediate window and in the Watches window as well, as shown here: