Change the display of your Visual Basic code

Microsoft Office Access 2003

Use the Immediate window of the Microsoft Visual Basic Editor to check the results of a line of Microsoft Visual Basic code. You can use the Immediate window to check the value of a control, field, or property; to display the result of an expression; or to assign a new value to a variable, field, column, or property. The Immediate window is a kind of scratchpad window in which statements, methods, and Sub procedures are evaluated immediately.

  1. Do one of the following:

    To display the Immediate window at any time in Microsoft Access, press CTRL+G.

    To use the Immediate window at a certain point during execution of the code, suspend execution at that point and then click Immediate Window Button image on the Debug toolbar.

  2. Do one of the following:

    Type a statement, method, Function, or Sub procedure call in the window, and then press ENTER.

    View the results of an expression in the Immediate window by entering the Print method of the Debug object, followed by the expression. You can use a question mark (?) as shorthand for the Print method.

    For example, Microsoft Visual Basic displays the value returned by the FirstOfNextMonth custom function if you type either of the following lines in the Immediate window:

    Debug.Print FirstOfNextMonth()
    
    ? FirstOfNextMonth()
    						

ShowChange how Visual Basic code is displayed in the Code window

You can change the color, font, font size, and tab width used when you type Visual Basic code in the Code window. You can also specify whether the entire module is displayed (default) or each procedure is displayed individually in the Code window, and set various additional options for working in the Code window.

  1. On the Tools menu, click Options.
  2. Set the appropriate options.

ShowDisplay a list of relevant objects, properties, and methods in the Visual Basic Editor

When Auto List Members is selected, Microsoft Access assists you in completing statements while you're writing Visual Basic code.

  1. On the Tools menu, click Options.
  2. Click the Editor tab.
  3. Under Code Settings, make sure Auto List Members is selected.

Note  To make the list disappear, press ESC.

ShowDisplay syntax information in the Visual Basic Editor

You can set the Visual Basic Editor to display syntax information in the Code window. When you type a method or the name of an existing procedure followed by a space or opening parenthesis, a tip automatically appears giving syntax information about the method or procedure, such as the arguments for you to specify.

  1. On the Tools menu, click Options.
  2. Click the Editor tab.
  3. Under Code Settings, make sure Auto Quick Info is selected.

ShowDisplay the value of a variable or expression in the Visual Basic Editor when code is suspended

You can check the value of a variable or an expression while code is suspended. Rest the mouse pointer on a variable or expression to display its current value.

  1. On the Tools menu, click Options.
  2. Click the Editor tab.
  3. Under Code Settings, make sure Auto Data Tips is selected.

ShowDisplay the value of variables in the Locals window of the Visual Basic Editor

In the Locals window, Microsoft Access automatically displays the name, current value, and type of all the variables and objects in the current procedure. The values in the Locals window are updated each time you suspend code execution. You can change the value of a variable in the Locals window by selecting the existing value and entering the new value.

  1. Suspend execution of Visual Basic code.

    ShowHow?

    When you suspend execution of Microsoft Visual Basic code, the code is still running but is paused between running statements. While your code is suspended, you can do debugging tasks such as checking current variable values and running each line of code one at a time. To make Microsoft Visual Basic pause your code, you can set a breakpoint.

    1. In the Visual Basic Editor, move the insertion point to a line of code that isn't already a breakpoint or declaration.
    2. Click Toggle Breakpoint Button image on the Debug toolbar.
    3. Do one of the following:

      To clear a breakpoint, move the insertion point to the line of code on which the breakpoint has been set, and then click Toggle Breakpoint Button image on the Debug toolbar.

      To resume running the code, click Run Sub/UserForm on the Run menu.

    Note  You can also suspend code by adding a Stop statement to a procedure or by pressing CTRL+BREAK while the code is running.

  2. Click Locals Window on the View menu.