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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating Status Bar as Module progresses

Status
Not open for further replies.
Nov 8, 2000
12
GB
I have an Access module that is basically a series of runcmd.dosql commands. How can I get the status bar to display which command I am on.

e.g.
If the module is running docmd.runsql "update names... etc"

I want to add a line in the script that makes the status bar say 'Updating Names Table'

Basically - what is the command to change the text in the Status Bar ??
 
I did a simple search in the Help file for Status Bar and this is what I found...
Code:
You can use the SysCmd function to perform one of the following functions:

·	Display a progress meter or optional specified text in the status bar.
·	Return information about Microsoft Access and its associated files.
·	Return the state of a specified database object to indicate whether the object is open, is a new object, or has been changed but not saved.

For example, if you are building a custom wizard that creates a new form, you can use the SysCmd function to display a progress meter indicating the progress of your wizard as it constructs the form.

Syntax

ReturnValue = SysCmd(action[, text][, value])
ObjectState = SysCmd(action[, objecttype][, objectname])

The SysCmd function has the following arguments.

Argument	Description
action	One of the following intrinsic constants identifying the type of action to take.
The following set of constants applies to a progress meter. The SysCmd function returns a Null if these actions are successful. Otherwise, Microsoft Access generates a run-time error.
acSysCmdInitMeter	Initializes the progress meter. You must specify the text and value arguments when you use this action.
acSysCmdUpdateMeter	Updates the progress meter with the specified value. You must specify the text argument when you use this action.
acSysCmdRemoveMeter	Removes the progress meter.
acSysCmdSetStatus	Sets the status bar text to the text argument.
acSysCmdClearStatus	Resets the status bar text.
The following set of constants provides information about Microsoft Access.
acSysCmdRuntime	Returns True (–1) if a run-time version of Microsoft Access is running.
acSysCmdAccessVer	Returns the version number of Microsoft Access.
acSysCmdIniFile	Returns the name of the .ini file associated with Microsoft Access.
acSysCmdAccessDir	Returns the name of the directory where Msaccess.exe is located.
acSysCmdProfile	Returns the /profile setting specified by the user when starting Microsoft Access from the command line.
acSysCmdGetWorkgroupFile	Returns the path to the workgroup file (System.mdw).
The following constant provides information on the state of a database object.
acSysCmdGetObjectState	Returns the state of the specified database object. You must specify the objecttype and objectname parts when you use this action value.
text	A string expression identifying the text to be displayed left-aligned in the status bar. This argument is required when the action argument is acSysCmdInitMeter, acSysCmdUpdateMeter, or acSysCmdSetStatus; this argument isn't valid for other action argument values.
value	A numeric expression that controls the display of the progress meter. This argument is required when the action argument is acSysCmdInitMeter; this argument isn't valid for other action argument values.
objecttype	One of the following intrinsic constants:
acTable
acQuery
acForm
acReport
acMacro
acModule
This argument is required when the action argument is acSysCmdGetObjectState; this argument isn't valid for other action argument values.
objectname	A string expression that is the valid name of a database object of the type specified by the objecttype argument. This argument is required when the action argument is acSysCmdGetObjectState; this argument isn't valid for other action argument values.
Remarks

By calling the SysCmd function with the various progress meter actions, you can display a progress meter in the status bar for an operation that has a known duration or number of steps, and update it to indicate the progress of the operation.
To display a progress meter in the status bar, you must first call the SysCmd function with the acSysCmdInitMeter action argument, and the text and value arguments. When the action argument is acSysCmdInitMeter, the value argument is the maximum value of the meter, or 100 percent.

To update the meter to show the progress of the operation, call the SysCmd function with the acSysCmdUpdateMeter action argument and the value
 argument. When the action argument is acSysCmdUpdateMeter, the SysCmd function uses the value argument to calculate the percentage displayed by the meter. For example, if you set the maximum value to 200 and then update the meter with a value of 100, the progress meter will be half-filled.

You can also change the text that's displayed in the status bar by calling the SysCmd function with the acSysCmdSetStatus action argument and the text argument. For example, during a sort you might change the text to "Sorting...". When the sort is complete, you would reset the status bar by removing the text. The text argument can contain approximately 80 characters. Because the status bar text is displayed by using a proportional font, the actual number of characters you can display is determined by the total width of all the characters specified by the text argument.

As you increase the width of the status bar text, you decrease the length of the meter. If the text is longer than the status bar and the action argument is acSysCmdInitMeter, the SysCmd function ignores the text and doesn't display anything in the status bar. If the text is longer than the status bar and the action argument is acSysCmdSetStatus, the SysCmd function truncates the text to fit the status bar.
You can't set the status bar text to a zero-length string (" "). If you want to remove the existing text from the status bar, set the text argument to a single space. The following examples illustrate ways to remove the text from the status bar:

varReturn = SysCmd(acSysCmdInitMeter, " ", 100)
varReturn = SysCmd(acSysCmdSetStatus, " ")

If the progress meter is already displayed when you set the text by calling the SysCmd function with the acSysCmdSetStatus action argument, the SysCmd function automatically removes the meter.
Call the SysCmd function with other actions to determine system information about Microsoft Access, including which version number of Microsoft Access is running, whether it is a run-time version, the location of the Microsoft Access executable file, the setting for the /profile argument specified in the command line, and the name of an .ini file associated with Microsoft Access.

Note   Both general and customized settings for Microsoft Access are now stored in the Windows Registry, so you probably won't need an .ini file with your Microsoft Access application. The acSysCmdIniFile action argument exists for compatibility with earlier versions of Microsoft Access.

Call the SysCmd function with the acSysCmdGetObjectState action argument and the objecttype and objectname arguments to return the state of a specified database object. An object can be in one of four possible states: not open or nonexistent, open, new, or changed but not saved.
For example, if you are designing a wizard that inserts a new field in a table, you need to determine whether the structure of the table has been changed but not yet saved, so that you can save it before modifying its structure. You can check the value returned by the SysCmd function to determine the state of the table.

The SysCmd function with the acSysCmdGetObjectState action argument can return any combination of the following constants.

Constant	State of database object
acObjStateOpen	Open
acObjStateNew	New
acObjStateDirty	Changed but not saved
Note   If the object referred to by the objectname argument is either not open or doesn't exist, the SysCmd function returns a value of zero.
Hope that helps...

Terry M. Hoey
th3856@txmail.sbc.com

Ever notice that by the time that you realize that you ran a truncate script on the wrong instance, it is too late to stop it?
 
Yes, but be aware that Ms. Access will "prempt" the status bar for it's "own devices" and your "message" may be overwritten.

I have usually found that a textbox which displays the "name" of an operationor a series of check boxes or option buttons with the labels set to the "name"s of the processes (where I manipulate the values in of the controls to indicate "progress") is a better soloution for advising a User of the status/progress of complex evoloutions.

MichaelRed
mred@duvallgroup.com
There is never time to do it right but there is always time to do it over
 
Good call, Michael...

Terry M. Hoey
th3856@txmail.sbc.com

Ever notice that by the time that you realize that you ran a truncate script on the wrong instance, it is too late to stop it?
 
Terry - no it doesn't help really - all I want to now is if I want the Status bar to say "Hello Terry", then what would the code be.
 
I created a test MDB that this works for. Send me an email and I will send it to you...


Terry M. Hoey
th3856@txmail.sbc.com

Ever notice that by the time that you realize that you ran a truncate script on the wrong instance, it is too late to stop it?
 
To set the Status Bar text type:

Syscmd acSysCmdSetStatus, "Hello Terry"

To reset the Status Bar (to whatever Access wants in it) type:

Syscmd acSysCmdClearStatus

Not too hard. :) Durkin
alandurkin@bigpond.com
 
The example I created has a form with a check box. When the box is checked, the status bar says "The checkbox is checked". When the box is checked, the status bar says "The checkbox is not checked".

I agree, not too hard, but I didn't know how to do it until Julie posted the question...


Terry M. Hoey
th3856@txmail.sbc.com

Ever notice that by the time that you realize that you ran a truncate script on the wrong instance, it is too late to stop it?
 
Terry et al,

To see why this is not really the way to go.


Add some trivial (do nothing) queries to the process/form so that when the check box "checked", you go off and do something else (or add a command button which does the "something"). Now try the "function". Depending on your implementation details, you may see the "intended" message - the Ms. Access will overwrit the text.



MichaelRed
mred@duvallgroup.com
There is never time to do it right but there is always time to do it over
 
Michael, I agreed with your earlier post that a messagebox was the better way to go. But for whatever reason, it seems that Julie wants to go with the status bar. We can point out problems or better solutions, but realistically, we are still here to provide what the "customer" wants.


Terry M. Hoey
th3856@txmail.sbc.com

Ever notice that by the time that you realize that you ran a truncate script on the wrong instance, it is too late to stop it?
 
Terry,

No attempt to provide an alternate soloution from me. I was/am just tying to show how the problem can (easily) be seen. After that "whatever Lola wants ...."



MichaelRed
mred@duvallgroup.com
There is never time to do it right but there is always time to do it over
 
I agree... ::)

Terry M. Hoey
th3856@txmail.sbc.com

Ever notice that by the time that you realize that you ran a truncate script on the wrong instance, it is too late to stop it?
 
Hi,

I just read this.
What about changing the status bar so that it contains more then one field.

as Access has loads as standard. FernandezD
At your service.
Unix systems Admin
 
Using the Application Title (or - when maximzied - the form titles) has the advantage that the Text also appears in the QuickInfo of the TaskBar Icon of Windows (I use this for %-Runs).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top