Abort Query button?

malxvc

Registered User.
Local time
Yesterday, 18:32
Joined
Sep 12, 2012
Messages
21
On a form, I have a subform that requeries a table based on the criteria entered in by the user. The table this query is running through is quite large, and in some instances, could return thousands of records.

Rather than having the user sit there for 2 hrs and wait, is there a way to stop the query from running? A command button that can abort the query and allow the user to enter in different criteria?

Is ctrl + break the solution? If so, is there a way to code that keyboard shortcut to a command button?
 
Would it not be a better idea to fix the query.

Thousands of Records is not by any means large.

The stoping of a query seems counter productive. Either you want the info or not.
 
Two hours to return the results from a query! :eek:

I'm certainly no expert but that seems an like an incredible amount of time. I think I'd be asking what can be done to speed that up first.
 
The amount of records and the time it takes to run the query are in no way related to the functionality I am looking to add to the form. What I said there isn't even true - I just thought it would help me find help if I were to explain what I want the "Abort" button to do, i.e. a query takes a really long time to process and pulls a lot of records, how can I cancel the query. If the query takes more than 3 seconds to run, the user will know they entered incorrect criteria - how can I program a button to stop execution of the query without timing out the form.
 
Can't you wait 3 seconds. That is not much time to wait.
 
Thanks for clarifying that 3 seconds is not a substantial amount of time.

Now back to the original point of the post - the amount of time and the amount of records the query is pulling are insignificant, they were only added to help explain what I want the functionality of the button to do.

An "Abort" button.

A user clicks a button that searches a table by way of a requery. I am not looking to restructure my query or my form - all I want to know is if there is a way for the user to abort the query search. A button to stop the subform from requerying.
 
I don't believe there is anything built into Access to do this.

The only thing I could suggest is Ctrl Break.

Still a manual action but better than Alt Ctrl Delete as this may corrupt some Data.

I still believe you should be looking at the query design. But that is not what you want.
 
I'm fine with ctrl break, but is there a way execute that keyboard shortcut with a command button?
 
Yes there is.

Will get back to you a a few minutes after I check something out
 
Using the On Click event try
Code:
SendKeys "^ {BREAK}"

If this does not work select SendKeys and Press F1 for help.

This code is untested. I have not used Send Keys for years.
 
The appropriate code is SendKeys ("{BREAK}") - works like a charm.

Thank you for your help.
 
Thanks for the feedback.

It appears that there is no need for "Ctrl"

Interesting.
 
But just an FYI - SendKeys is not completely reliable and may not work in Access in later versions of Windows. You just need to know.
 
I don't believe there is anything built into Access to do this.

The only thing I could suggest is Ctrl Break.

Still a manual action but better than Alt Ctrl Delete as this may corrupt some Data.

I still believe you should be looking at the query design. But that is not what you want.

I am in agreement with RainLover that you need to review your Query Design, because It sounds like you might have a Cartesian Join. I have had Queries that returned over 50,000 records in a few seconds, and others (with Cartesian Joins) that could not return 50 records in 10 minutes.

If you are able to show us the Query, we might be able to be of more help to you.

-- Rookie
 

Users who are viewing this thread

Back
Top Bottom