Show All

Show the results of a line of Visual Basic code

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 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()