markmarko said:
I'd like to make a button that users (using Access Runtime) can click to
cancel a slow procedure or query...
Is it possible to do this, and any advice on how to do it?
Hi markmarko,
You can provide the user a means of killing a slow procedure, but AFAIK
not a slow query.
For slow VB[A] procedures you need to know where the trouble spots are.
You can handle user requests to break by placing a command button on
your form and doing something like this in code (untested):
Private BreakRequest as Boolean ' declare this in the module's global area
Private Sub Command1_click()
BreakRequest = true
End Sub
Private Sub ReallyLongProcedure
BreakRequest = false
' begin long loop
Do
' a bunch of time-consuming stuff
DoEvents ' very important to include this
If BreakRequest Then
Msgbox "Break requested"
Exit Sub
End If
Loop Until HellFreezesOver
End Sub
Of course, you will have to think about what will happen if the
procedure is halted before completion.
With queries it's a different story. Once you send Jet off on a wild
goose chase, control events will not fire immediately. They might queue
up until Jet comes back, but that's not necessarily what you want to
happen. One thing that /does/ (usually) work to kill a query is pressing
Ctrl+Break, but I can't think of a way to detect this sort of
intervention in code.
HTH