How to show progress on status bar when running code (not queries)

大兔子大兔子 提交于 2019-12-02 07:17:38

Call DoEvents after each SysCmd call. That will signal Windows to update the display before your code advances.

In this function, each status bar message is visible before the next is displayed.

Function PutMessageInStatusBar2()
    Const lngMilliseconds As Long = 1000

    SysCmd acSysCmdSetStatus, "Before loop 1"
    DoEvents
    Sleep lngMilliseconds
    SysCmd acSysCmdSetStatus, "Before loop 2"
    DoEvents
    Sleep lngMilliseconds
    SysCmd acSysCmdSetStatus, "Before loop 3"
    DoEvents
    Sleep lngMilliseconds
    SysCmd acSysCmdSetStatus, "Done."
    DoEvents
    Sleep lngMilliseconds

    SysCmd acSysCmdClearStatus

End Function

Sleep is based on a Windows API method and is declared in the Declarations section of a standard module:

Option Compare Database
Option Explicit
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!