473,425 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,425 software developers and data experts.

How to cancel/stop code execution

Hi everyone. I'm creating an application inside Access 2007. The application will retrieve data from various locations on my company's network servers.

Depending on the time of day, alignment of the planets, other unfathomable mysteries sometimes my company's network is very, very slow.

I would like to provide the user of my application with a "Cancel" button on a form that will cancel/stop execution of the code (at whatever point it may be at) if the user clicks the button.

Is there some sort of DoCmd method or something else I can call to cancel/stop code execution in Access?

I could use the "CancelEvent" method. But to use this method, I must insert it at pre-determined points in the code, and then test to see if the user has selected the cancel button. It would work, but it's not as instantaneous as I wuld like. Plus, if execution hangs because of a slow network (which is the condition I'm most concerned about) if it doesn't happen to be a the proper spot in my code, the CancelEvents method wont be called.

I could also instruct the user to hit "Ctrl-Break" on the keyboard to stop execution, but that would produce a error dialog box which the user must learn to hit the "End" button. And besides, I don't know if users could REMEMBER the "Ctrl-Break" combination. :-)

Any thoughts or suggestions are greatly appreciated.

Thanks,
sphinney
Oct 24 '08 #1
4 27931
DonRayner
489 Expert 256MB
You could use the on timer event from a hidden form to check the state of a public variable that you set with the cancel button and then have it do the cancel event when it detects the change.
Oct 24 '08 #2
NeoPa
32,556 Expert Mod 16PB
Unfortunately, most code run in Access is synchronous.

A timer event could certainly be triggered, but even a "Stop" statement in there would, I'm pretty sure, be both unsafe and not give you the solution you want.

Remember, when queries are run from non-Access based data sources, they are also generally synchronous and they leave the Access VBA suspended, so you can't even check for the status of a variable.
Oct 25 '08 #3
Looks like my best bet is to go with the CancelEvent method. It works well enough. I just thought there might be some other command/method that would work better.

Thanks for your time and thoughts DonRayner and NeoPa!

sphinney
Oct 27 '08 #4
NeoPa
32,556 Expert Mod 16PB
No worries :)

Just sorry we didn't have any more to add.
Oct 27 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Jo | last post by:
Hi, I have a small (hopefully!) problem. I have two buttons on my web page and when button A is clicked, the code behind takes about 3 seconds to execute. While it's executing though, I don't want...
1
by: Default | last post by:
Hi, I am new to C#, that is why I am not sure what kind of problem it is: Is VS files corrupted , or something else. that is the problems description: I am working on a small database project. I am...
5
by: Adrian Enders | last post by:
I have something that I have never seen before in a MS development product. I have a pretty simple call to a network directory that looks something like this ... Dim dirFolder As...
0
by: Matt | last post by:
I'm attempting to load a form, query a database, and update a progress bar on the same form. I want the form to load and activate/enable the form's cancel button while the code continues to...
9
by: Rea | last post by:
Hi eb I set some 'Stop' statements and also visual breakpoints in asp code (vbscript). I am doing that in Microsoft Script debugger. Than I refresh the original page and expect execution to halt...
1
by: Sabiyur | last post by:
Hi All, I don't know whether this is the right forum to post this question. If not, Please forgive me. I want to write my own tool which can trace the code execution (print the sequence of...
4
by: Ralphz | last post by:
Hi How do I stop JavaScript execution when I encounter an error? Is there something similar to PHP's exit or die function? Thanks Ralph
3
by: =?Utf-8?B?UmludSBHb3BhbGFrcmlzaG5hIFBpbGxhaQ==?= | last post by:
Hi All, I have a ASP/C# application that connect to Oracle database . After issuing my SQL query if I close the browser or move into another page ( ie whle executing in the databse serevr) will...
2
by: Bruno Rafael Moreira de Barros | last post by:
index.php --- inlcude 'application.php'; functions.php --- function test1() { trigger_error('My error'); return FALSE;
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.