Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Equivalent of Excel's EnableCancelKey in Access?

Posted on 2013-01-05
4
Medium Priority
?
1,343 Views
Last Modified: 2013-03-01
I want the user of an Access database to be able to interrupt and exit procedures that involve long loops.

I could trap the KeyDown event of <Escape> so that it changes the value of a global variable whose value gets checked within the loop and so permits code execution to pass out of it, but that would slow down the procedure even further.

Does Access have an equivalent of Excel's Application.EnableCancelKey property (set to xlErrorHandler would do the trick), or does anyone have their own improvised equivalent?

Thanks.
0
Comment
Question by:TimHudspith
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 40

Expert Comment

by:als315
ID: 38746396
You can interrupt execution with Ctrl+Break keys.
0
 

Author Comment

by:TimHudspith
ID: 38746402
But that's not a proper solution is it? Variables and objects in the procedure don't get cleaned up properly.
0
 
LVL 29

Assisted Solution

by:IrogSinta
IrogSinta earned 750 total points
ID: 38746785
I don't believe there is.  I would do it the same way as you mentioned although I would keep the scope of the variable just to the form alone (Dim it the top of the form's module).  Of course you would need to add the DoEvents command in your loop so that the Escape key press could be captured, it sounds like you're already aware of this.
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 750 total points
ID: 38751210
<Variables and objects in the procedure don't get cleaned up properly. >
AFAICT, EnableCancelKey does not do this either...
http://msdn.microsoft.com/en-us/library/office/aa214566%28v=office.11%29.aspx

To detect if the ESC key was pressed, you can use something like this:
Private Sub Form_KeyPress(KeyAscii As Integer)
    If KeyAscii = 27 Then
        MsgBox "Put code here to clean up variables, alert the user, and exit gracefully."
        'MsgBox "You pressed the ESC key"
    End If
End Sub


JeffCoachman
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Outlook for dependable use in a very small business   This article is about using the Outlook application (part of Microsoft Office) in a very small business, or for homeowners where dependability and reliability are critical requirements. This …
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question