Search code examples
ms-accessvbams-access-2010statusbar

Access SysCmd function not working as expected for some action values


I've read the relevant historical material and this is not the same issue others have had. Adding DoEvents has no effect.

First Problem

RetVal = SysCmd(4, "Here's an Update!") clears the status bar text and meter, instead of updating the text. I have tested this in a sub and in the immediate window using ?SysCmd(4, "some text").

Second Problem

More confusing is that SysCmd(3) and SysCmd(5) both entirely remove the status bar, text and meter. SysCmd(3) is described in documentation:

When the argument is 3, the progress meter is removed from the status bar.

For SysCmd(5) on another page:

When the action argument is 5, the status bar text set by the previous SysCmd() function is removed.

Contrary to these descriptions, the entire status bar is removed.

I even tried testing the suggested sub from Microsoft:

Function StatusBar ()
     Dim RetVal As Variant
     RetVal = SysCmd(4, "The rain in Spain falls mainly ...")
     MsgBox "Press OK when you are ready to finish!"
     RetVal = SysCmd(5)
  End Function

Testing this resulted in only the message box.

Everything Else Works

Everything else works fine, as far as I can tell. These work as expected:

RetVal = SysCmd(1, "Beginning Queries...", 10) 'adds the status bar 
RetVal = SysCmd(2,1) 'moves the meter

Adding the constant names (i.e. acSysCmdSetStatus) does not seem to have any effect in Access 2010 (since this is Access VBA, not VBS).


Solution

  • The problem I had was all about a bad misconception. The SysCmd method does a lot of things and it's a little overwhelming.

    At the very bottom of Access, we have the status bar. The text on the very bottom left is the Status Bar Text. This is controlled via the acSysCmdSetStatus (value of 4) and acSysCmdClearStatus (value of 5).

    This text cannot be used at the same time as the Status Bar Progress Meter, which is on the bottom right of the status bar. It has its own text.

    The misconception above is the idea that the status bar text actions change the text of the status bar progress meter. And they don't.

    For reference on SysCmd action values, see here.