I would like to have the capability to break/cancel routines (recordsets) by pressing the Esc key, especially when looping through large number of records. I would expect to use some function that scans for a key-press at the bottom of the loop and trap the Acsii value of the ESC key. However, I am either trying to do something Access doesn't support or just can't find the correct function. I'm sure that I'm overlooking the solution....
From: Shamil Salakhetdinov <shamil@marta.darts.spb.ru>
To: <accessd@mtgroup.com>
Subject: Re: [accessd] Breaking from a Loop using ESC key?
Date: 27 March 1999 3:12
Tanya,
I would recommed to use a form with Cancel button and probably ProgressBar. Enclosed you'll
find a template solution for simple popup form with Cancel button...
HTH,
Shamil
1. Class module
Private Const mcstrCMyCancel As String = "CMyCancel" Dim mfrm As Form_frmCancel Private Sub Class_Initialize() Set mfrm = New Form_frmCancel mfrm.Visible = True End Sub Private Sub Class_Terminate() Set mfrm = Nothing End Sub Public Property Get CancelClicked() As Boolean DoEvents CancelClicked = mfrm.CancelClicked End Property
2. Code Behind Form
Private mfCancelClicked As Boolean Public Property Get CancelClicked() As Boolean CancelClicked = mfCancelClicked End Property Public Property Let CancelClicked(vf As Boolean) mfCancelClicked = vf End Property Private Sub cmdCancel_Click() Me.CancelClicked = True End Sub
3. Test
Public Sub EndlessLoop()
Dim obj As New CMyCancel
Do While 1
If obj.CancelClicked Then
Exit Do
End If
Loop
Set obj = Nothing
End Sub
| HOME TOPICS |
Copyright © 1999 by Shamil Salakhetdinov.
|
| Last updated: October 10, 2006
Published also here at 4TOPS: Breaking from a Loop using ESC key |
|