Cancel / stop command? (1 Viewer)

option

Registered User.
Local time
Today, 01:34
Joined
Jul 3, 2008
Messages
143
Hey guys,
I'm trying to build a cancel option into my database that would stop whatever code is being worked "dead in its tracks" so to speak. I've searched for examples, but nothing relevant appears in the searches. Any ideas how I could pull this off??
 

Vonnie

Registered User.
Local time
Yesterday, 22:34
Joined
Aug 21, 2008
Messages
57
There has been some coding posted in this forum for using the Esc key to break into loops. You might search for that.
Private Declare Function apiGetAsyncKeyState Lib "user32" _
Alias "GetAsyncKeyState" _
(ByVal vKey As Long) _
As Integer

Good luck
 

option

Registered User.
Local time
Today, 01:34
Joined
Jul 3, 2008
Messages
143
Hey guys,
I'm trying to build a cancel option into my database that would stop whatever code is being worked "dead in its tracks" so to speak. I've searched for examples, but nothing relevant appears in the searches. Any ideas how I could pull this off??

Vonnie: are you saying that the escape key is being used as a "break point"? If so, thats not going to cancel the operation, but merely pause it and we don't want the user interfering with any of the code. Thanks though :). I've tried sendkeys using Ctrl + Break, but that doesn't work. The process that I am running is quite lengthy, and if it is going take longer than the time the user has available, we want to be able to hit cancel or stop and have the program stop what its doing. I don't want to close the form because there are other processes that can be run besides the one in question.
 

Vonnie

Registered User.
Local time
Yesterday, 22:34
Joined
Aug 21, 2008
Messages
57
If you capture the ESC key, then you can do whatever code you want at that point - you don't have to let them into the coding. You want to stop the coding but not have the user involved at all, is that it? You stop code execution and then what?
 

Vonnie

Registered User.
Local time
Yesterday, 22:34
Joined
Aug 21, 2008
Messages
57
If you are in the middle of a routine the END keyword ends the routine.
It doesn't even go to the End Sub
 

WayneRyan

AWF VIP
Local time
Today, 06:34
Joined
Nov 19, 2002
Messages
7,122
Option,

This is a VERY simplistic example.

hth,
Wayne
 

Attachments

  • Demo.zip
    10.6 KB · Views: 108

option

Registered User.
Local time
Today, 01:34
Joined
Jul 3, 2008
Messages
143
Wayne & Vonnie, thank you both for all of the help! I've got my project back on track and its thanks to you!
 

Guus2005

AWF VIP
Local time
Today, 07:34
Joined
Jun 26, 2007
Messages
2,642
Mind you that DoEvents slows your program down quite a bit, so be carefull when you use them.

HTH:D
 

Users who are viewing this thread

Top Bottom