|
-
Sep 16th, 2000, 12:13 PM
#1
Thread Starter
Frenzied Member
Hi,
What is the proper way to let the user cancel a running process?
For example, I have an application which when the user clicks the start button, a function is called and begins it's processing.. I have included a Cancel button on the form just in case the user does not want to complete the processing.
What I did is created a msgbox that pops up when the user hits Cancel which asks them if they really wish to cancel the process. If they hit Yes, then it stop, otherwise, it continues.
Here's the code I used:
Code:
Private Sub cmdCancel_Click()
Dim xVar As Integer
xVar = MsgBox("Are you sure you wish to cancel?", _
vbQuestion + vbYesNo)
If xVar = 6 Then
'-- cancel operation
Unload Me
End If
End Sub
But I think I'm missing something because the following situation occurs:
When the user clicks Cancel and hits Yes, the Form unloads but an error occurs because the process that is being canceled was using an ADO recordset and I put RS.Close in the Form_Unload event to close the connection but it seems that the process wants to keep continuing. The error states "Operation is not allowed when the object is closed."
This is obviously due to the fact that I'm closing the recordset but I have no choice. I do not want to keep it open.
My question is, how do I stop the process dead in it's tracks if the user selects Yes so that it does not try to process any further?
Any help would be appreciated..
Dan
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|