Access Tip of the Day |
|||
Easily check a calculated result in break mode (Access 97/2000/2002) You can use the Watch Window to monitor a volatile expression result as you debug a VBA code procedure. Sometimes, you may want to check part of a calculation without going to the trouble of setting up a watch. As you may already know, you can examine a variable or object property values by hovering your mouse pointer over a word when viewing a VBA procedure in break mode. What you may not know is that you also can use this approach to examine a portion of an expression. For example, consider this simple procedure: Sub ExpressionTest() Dim x As Long Dim y As Double x = InputBox("Enter A Number:") y = x * 1.15 / 12 Debug.Print y End Sub The procedure returns the final result stored in y, but what if you want to see the result of just the "x *1.15" portion of the calculation? To do so, click in the bar to the left of the line containing the calculation for the y variable to set a breakpoint (or click in the line of code and press [F9]). Then, run the procedure. After you enter a number in the input box, the procedure halts at the breakpoint. If you hover your mouse over the x variable, you'll see the number you specified. Now, select just "x * 1.15" and hover your mouse pointer over the selection. You'll now see the calculated result for that part of the complete expression. If you select the expression "x * 1.15 / 12" and hover your mouse pointer over the selection you'll see the result that will be stored in y when you continue running the procedure. Keep in mind that this technique works with expressions involving object properties as well. For instance, in the statement: For x = 0 To lst.ListCount - 1 you can select just "lst.ListCount - 1" to determine the loop's upper bound. (Content provided by Element K Journals) (Note: Your browser is set to refuse cookies. As a result, you may frequently see previously-viewed tips)
|
|||
Copyright © 2001 - 2025 MJ Technologies, LLC. All rights reserved. | |||