
status bar and cancel button
Several issues are found here:
1. Status meter usage
2. Cancel on demand from a button
3. Rolling back changes
1. Status Meter Usage: This is simply a "percent done" thing. The
InitMeter call sets 100% and the text on the meter, and is called only once.
The UpdateMeter call is done as often as you want the meter to move; usually
placed in your loop. Finally the RemoveMeter call is done once, and the
meter disappears. Some people intialize it with a 100 first, then
updateMeter it with a 20, 40, 60, 100 etc., then dispose of it with a
RemoveMeter call. (Of course, all of this is in the SysCmd function, which
you must know by now.)
2. Cancel on Demand: Status meters don't have buttons to click on. So
you'll need a Cancel button on your form. When it is pressed, it can be
programmed to set a boolean flag. Reset the flag before your code begins;
then occasionally throughout your loop code, you want to check the flag
status and jump to a piece of code to handle the exception. In that piece
of code, simply roll back the changes--see my next point.
3. Rolling back the Changes: This is a simple use of the Transaction
concept: Begin a transaction, do your fancy stuff, and if it was all
successful, commit the transaction; if an error happened (or the user
presses your cancel button) then rollback the transaction. These three
methods are found in the workspace object. Workspace.BeginTrans,
Workspace.CommitTrans, and Workspace.Rollback.
I'm leaving out the details because you probably can look them up now that
I've given you a push in the right direction.
Shaun Merrill
I have a function that does the following:
1. Opens a graphics program using Shell
2. Uses a loop function to send DDE commands to work the graphics
program for part(s) selected on a multi-selected box.
3. Does a few forms!formname!textbox = whatever
4. Closes the DDE commands and everything else
I would like to have a status bar meter running during this time so the
user knows the status of the function (it could range from seconds to
minutes).
I looked at the MS KB on status meter, but I don't understand how to
apply it to my function.
Also, how can I add a cancel button to the status bar meter? And if the
user click the cancel button, I want Access to stop wherever it is at in
the function. If it's in the middle of DDE commands for the graphics
program, I want Access to close the program. If it's in the middle of
copying data, i want to it cancel and undo the changes.
Thanks.
Ngan