Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use the Status bar to your advantage.

Access 101

How to use the Status bar to your advantage.

by  RemyS  Posted    (Edited  )
This will come in handy, particularly when building a database which will be used by others.

The Status bar is the bar at the bottom of the screen, which usually says "Ready", or shows you the progress of a query. However it doesn't always tell you what Access is doing, or at what stage of a Subroutine it is at.

You can use it as a simple, more informative means of let users know what is going on.

First you will need to declare a Variant:

[color blue] Dim [/color] varStatus [color blue] As Variant[/color]

You might also want to declare a String for any text you would like to display:

[color blue] Dim [/color] strStatus [color blue] As String[/color]


You then use this variant to assign any message to the Status bar with the acSysCmdSetStatus action of the SysCmd function, like so:

strStatus = "The database is searching for the most recent file..."
varStatus = SysCmd(acSysCmdSetStatus, strStatus)


You can also display a progress meter with the acSysCmdInitMeter action, like so:

strStatus = "Importing four XLS files"
varStatus = SysCmd(acSysCmdInitMeter, strStatus, [color red]21[/color])

The value [color red]21[/color] (identified as [Argument3]) determines the 100% value
(There are 20 blocks in the progress meter, but the meter starts with one already filled in, so 21 is an easy value to use, unless you want to use 100 and true percentages values.)


The meter is updated whenever the acSysCmdUpdateMeter action is used, like so:

varStatus = SysCmd(acSysCmdUpdateMeter, [color red]5[/color])

The value [color red]5[/color] represents the amount of the progress meter to fill in. So here, 5 will fill in 5 blocks, 25% of the progress meter.


Once you have filled in the progress meter (or at any stage) you can either display another text statement, or another progress meter, but if you have finished you must remember to clear the Status bar with the acSysCmdClearStatus action, like so:

varStatus = SysCmd(acSysCmdClearStatus)


Note: you can only update the meter whilst the same procedure is running from which it was initiated. The update can be run from nested subroutines, but if the procedure is halted or ends, a new varStatus must be assigned.[color red][ul][li]Also remember to include the Status clear action in any error handling.[/li][li]And that, if you remove the Startup menu options, to keep the Display Status Bar checked. [/li][/ul][/color]


[color green]*********************************************************[/color]

The SysCmd function will also display system information about the database.

One which is particularly useful, if you design n-tier secured applications is:
Current_Workgroup = SysCmd(acSysCmdGetWorkgroupFile)
which can be used to determine if a user has opened the right Access shortcut to have access to secured features (i.e. "C:\Program Files\Microsoft Office\Office\MSACCESS.EXE" /wrkgrp C:\Winnt\system32\SECURE1.MDW).

[color green]**********************************************************[/color]
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top