[AccessD] Stop That Code!

John Ruff papparuff at attbi.com
Sun Apr 6 19:26:48 CDT 2003


Rocky,
 
You can use DoEvents and a "Cancel" button.
 
Create a Cancel button (cmdCancel) and when you press it, place the word
"Cancel" in the button's Tag Property.  Also, in the button that begins the
processing place  a line of code before the processing starts that says
cmdCancel.Tag="".  This way, if you have cancelled the process and want to
restart it, the cancel button's tag property is reset.
 
If you are running queries, just after each query add two lines of code
 
    DoEvents 
    If cmdCancel.Tag="Cancel" then Exit ' (or a GoTo Exit Label)
 
If you are running a loop then add the same two lines just after you start
the loop
 
For i = 1 to Total
    DoEvents 
    If cmdCancel.Tag="Cancel" then Exit ' (or a GoTo Exit Label)
    ...
Next i
 
or 
 
Do while not rs.eof
    DoEvents 
    If cmdCancel.Tag="Cancel" then Exit ' (or a GoTo Exit Label)
    ...
loop
 
As JC stated, you cannot stop a query once it has started, but you can stop
a process immediately after a query has finished.  I've used this procedure
quite a bit to do exactly what you are trying to do.
 
 

John V. Ruff - The Eternal Optimist :-) 
Always Looking For Contract Opportunities 

"Commit to the Lord whatever you do, 
        and your plans will succeed." Proverbs 16:3 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Rocky Smolin -
Beach Access Software
Sent: Sunday, April 06, 2003 10:37 AM
To: AccessD at databaseadvisors.com
Subject: [AccessD] Stop That Code!


Dear List:
 
I have some processes in an app which take a while to execute.  I generally
put something on the screen to show the user that progress is being made.
I'd like to give them the capability to abort the process by pressing the
ESC key.  Maybe they used data selection criteria to select 12 records and
instead selected 12,000.  Or made a mistake starting a long cost roll up or
calculation which they'd like to abort.
 
What's the simplest way to accomplish this?
 
 
MTIA,
 
Rocky Smolin
Beach Access Software
 
 
 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://databaseadvisors.com/pipermail/accessd/attachments/20030406/37977c65/attachment-0001.html>


More information about the AccessD mailing list