This article was previously published under Q105511
Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
Moderate: Requires basic macro, coding, and interoperability skills.
This article demonstrates how to use the SysCmd() function to displaycustom messages in the Microsoft Access status bar.
NOTE: This article assumes that you are familiar with Access Basic and withcreating Microsoft Access applications using the programming tools providedwith Microsoft Access. For more information on Access Basic, please referto the "Introduction to Programming" manual in Microsoft Access version1.x, or the "Building Applications" manual, Chapter 3, "Introducing AccessBasic" in version 2.0.
The SysCmd() function is documented in the manual "The Secrets ofAccessWizards," which is included with the Microsoft Access DistributionKit (ADK) version 1.1. You can use this function to change the text thatappears in the status bar. For example, you might want to change the statusbar to read "Sorting..." while a sort operation is taking place, and thenremove it when the operation is complete.
The SysCmd() function syntax is as follows:
SysCmd(<action> [, <text>])
Replace <action> with a numeric expression identifying the action to take.Valid entries are as follows:
4 - Set the status bar text to the text argument 5 - Reset the status bar text
Replace <text> with a string expression that will appear left aligned inthe status bar.
The SysCmd() function returns null, which is not used.
Setting Status Bar Text
When the action argument is 4, the string expression in the text argumentwill appear in the status bar. For example, type the following expressionin the Immediate window and the message "Sorting..." will appear in thestatus bar:
? SysCmd(4, "Sorting...")
Removing or Resetting the Status Bar Text
When the action argument is 5, the status bar text set by the previousSysCmd() function is removed. For example, type the following in theImmediate window and the "Sorting..." message will be removed:
The text argument can contain about 80 characters. Since the text in thestatus bar uses a proportional font, the actual number of characters youcan display is determined by the total width of all the characters in thetext argument.
You cannot set the status bar text to an empty string. If you want toremove the existing text in the status bar, set the text argument to asingle space.
How to Use SysCmd() in an Access Basic Function
The following sample function will place a message in the status bar,display a message box, and then remove the status bar text:
Create a new module called Status Bar Test.
Enter the following statement in the Declarations section:
Enter the following function:
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
To run the function, type the following in the Immediate window, and then press ENTER:
Microsoft Access Distribution Kit "The Secrets of AccessWizards," version1.1, page 30