Echo Method

Microsoft Access Visual Basic

Show All

Echo Method

       

Echo method as it applies to the Application object.

The Echo method specifies whether Microsoft Access repaints the display screen.

expression.Echo(EchoOn, bstrStatusBarText)

expression   Required. An expression that returns an Application object.

EchoOn  Required Integer. True (default) indicates that the screen is repainted.

bstrStatusBarText  Optional String. A string expression that specifies the text to display in the status bar when repainting is turned on or off.

Remarks

If you are running Visual Basic code that makes a number of changes to objects displayed on the screen, your code may work faster if you turn off screen repainting until the procedure has finished running. You may also want to turn repainting off if your code makes changes that the user shouldn't or doesn't need to see.

The Echo method doesn't suppress the display of modal dialog boxes, such as error messages, or pop-up forms, such as property sheets.

If you turn screen repainting off, the screen won't show any changes, even if the user presses CTRL+BREAK or Visual Basic encounters a breakpoint. You may want to create a macro that turns repainting on and then assign the macro to a key or custom menu command. You can then use the key combination or menu command to turn repainting on if it has been turned off in Visual Basic.

If you turn screen repainting off and then try to step through the code, you won't be able to see progress through the code or any other visual cues until repainting is turned back on. However, your code will continue to execute.

Note   Don't confuse the Echo method with the Repaint method. The Echo method turns screen repainting on or off. The Repaint method forces an immediate screen repainting.

Echo method as it applies to the DoCmd object.

The Echo method of the DoCmd object carries out the Echo action in Visual Basic.

expression.Echo(EchoOn, StatusBarText)

expression   Required. An expression that returns a DoCmd object.

EchoOn  Required Variant. Use True to turn echo on and False to turn it off.

StatusBarText  Optional Variant. A string expression indicating the text that appears in the status bar.

Remarks

If you leave the StatusBarText argument blank, don't use a comma following the echoon argument.

If you turn echo off in Visual Basic, you must turn it back on or it will remain off, even if the user presses CTRL+BREAK or if Visual Basic encounters a breakpoint. You may want to create a macro that turns echo on and then assign that macro to a key combination or a custom menu command. You could then use the key combination or menu command to turn echo on if it has been turned off in Visual Basic.

The Echo method of the DoCmd object was added to provide backward compatibility for running the Echo action in Visual Basic code in Microsoft Access for Windows 95. It's recommended that you use the existing Echo method of the Application object instead.

Example

As it applies to the Application object.

The following example uses the Echo method to prevent the screen from being repainted while certain operations are underway. While the procedure opens a form and minimizes it, the user only sees an hourglass icon indicating that processing is taking place, and the screen isn't repainted. When this task is completed, the hourglass changes back to a pointer and screen repainting is turned back on.

Public Sub EchoOff()

 ' Open the Employees form minimized.
    Application.Echo False
    DoCmd.Hourglass True
    DoCmd.OpenForm "Employees", acNormal
    DoCmd.Minimize
    Application.Echo True
    DoCmd.Hourglass False

End Sub

As it applies to the DoCmd object.

The following example uses the Echo method to turn echo off and display the specified text in the status bar while Visual Basic code is executing:

DoCmd.Echo False, "Visual Basic code is executing."