Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: unload event "you canceled the previous operation" error

Geek News

unload event "you canceled the previous operation" error
Sophia 12/27/2008 1:49:01 AM
Hi Everyone;

I posted this question yesterday, but cannot find it. So, here it is again.

I have a form with a subform. If the subform is empty, I want to advise the
user. I have a message box, which asks them if they want to fill in the
subform. If they choose "yes", then the error "you canceled the previous
operation" pops up. How can I remove this error or fix what is wrong? Any
help would be appreciated.

Here is the code for the unload of the form:

Dim intResponse As Variant

If SubfrmAssessment_Details_Admission.Form.RecordsetClone.RecordCount = 0 Then
intResponse = MsgBox("Enter an Admission Assessment", vbYesNo, "Admission
assessment is not done")

If intResponse = vbYes Then
DoCmd.CancelEvent
End If
End If

End Sub

Sophia

Re: unload event "you canceled the previous operation" error
"Jeanette Cunningham" <nnn[ at ]discussions.microsoft.com> 12/27/2008 11:29:55 AM
Hi Sophia
this is a common error which you can trap, so that it doesn't show.
The error is telling that the unload of the form was cancelled.

To trap that error, you need to get the error number for it. Next time you
run the form, write down the error number.

Now put some error handling code something like this:

Private Sub Form_Unload(Cancel As Integer)
On Error GoTo Err_Handler

If SubfrmAssessment_Details_Admission.Form.RecordsetClone.RecordCount = 0
Then
intResponse = MsgBox("Enter an Admission Assessment", vbYesNo, "Admission
assessment is not done")

If intResponse = vbYes Then
Cancel = true
End If
End If

Exit_Handler:
Exit Sub

Err_Handler:
If Err.Number = 2501 Then
Else
MsgBox Err.Number & " " & Err.Description
End If
End Sub

2501 is probably not the correct error number, replace it with the error
number you are getting for the error.
Now when the error occurs, it is trapped by the error handler instead of
appearing.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


"Sophia" <Sophia[ at ]discussions.microsoft.com> wrote in message
news:AC20EEC4-3B12-45A6-AA1A-77F049F5081A[ at ]microsoft.com...
[Quoted Text]
> Hi Everyone;
>
> I posted this question yesterday, but cannot find it. So, here it is
> again.
>
> I have a form with a subform. If the subform is empty, I want to advise
> the
> user. I have a message box, which asks them if they want to fill in the
> subform. If they choose "yes", then the error "you canceled the previous
> operation" pops up. How can I remove this error or fix what is wrong?
> Any
> help would be appreciated.
>
> Here is the code for the unload of the form:
>
> Dim intResponse As Variant
>
> If SubfrmAssessment_Details_Admission.Form.RecordsetClone.RecordCount = 0
> Then
> intResponse = MsgBox("Enter an Admission Assessment", vbYesNo, "Admission
> assessment is not done")
>
> If intResponse = vbYes Then
> DoCmd.CancelEvent
> End If
> End If
>
> End Sub
>
> Sophia
>


Re: unload event "you canceled the previous operation" error
Sophia 12/29/2008 10:31:02 PM
Jeanette: Thank you for the advise, but it isn't an error which has a
number, that I can find anyway. It is a message box that pops up, after the
user chooses "Yes" to the question, prior.

Any suggestions?

Sophia

"Jeanette Cunningham" wrote:

[Quoted Text]
> Hi Sophia
> this is a common error which you can trap, so that it doesn't show.
> The error is telling that the unload of the form was cancelled.
>
> To trap that error, you need to get the error number for it. Next time you
> run the form, write down the error number.
>
> Now put some error handling code something like this:
>
> Private Sub Form_Unload(Cancel As Integer)
> On Error GoTo Err_Handler
>
> If SubfrmAssessment_Details_Admission.Form.RecordsetClone.RecordCount = 0
> Then
> intResponse = MsgBox("Enter an Admission Assessment", vbYesNo, "Admission
> assessment is not done")
>
> If intResponse = vbYes Then
> Cancel = true
> End If
> End If
>
> Exit_Handler:
> Exit Sub
>
> Err_Handler:
> If Err.Number = 2501 Then
> Else
> MsgBox Err.Number & " " & Err.Description
> End If
> End Sub
>
> 2501 is probably not the correct error number, replace it with the error
> number you are getting for the error.
> Now when the error occurs, it is trapped by the error handler instead of
> appearing.
>
>
> Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
>
>
> "Sophia" <Sophia[ at ]discussions.microsoft.com> wrote in message
> news:AC20EEC4-3B12-45A6-AA1A-77F049F5081A[ at ]microsoft.com...
> > Hi Everyone;
> >
> > I posted this question yesterday, but cannot find it. So, here it is
> > again.
> >
> > I have a form with a subform. If the subform is empty, I want to advise
> > the
> > user. I have a message box, which asks them if they want to fill in the
> > subform. If they choose "yes", then the error "you canceled the previous
> > operation" pops up. How can I remove this error or fix what is wrong?
> > Any
> > help would be appreciated.
> >
> > Here is the code for the unload of the form:
> >
> > Dim intResponse As Variant
> >
> > If SubfrmAssessment_Details_Admission.Form.RecordsetClone.RecordCount = 0
> > Then
> > intResponse = MsgBox("Enter an Admission Assessment", vbYesNo, "Admission
> > assessment is not done")
> >
> > If intResponse = vbYes Then
> > DoCmd.CancelEvent
> > End If
> > End If
> >
> > End Sub
> >
> > Sophia
> >
>
>
>
Re: unload event "you canceled the previous operation" error
Marshall Barton <marshbarton[ at ]wowway.com> 12/30/2008 12:28:56 AM
Sophia wrote:

[Quoted Text]
>Jeanette: Thank you for the advise, but it isn't an error which has a
>number, that I can find anyway. It is a message box that pops up, after the
>user chooses "Yes" to the question, prior.
>
>Any suggestions?
>
>Sophia
>
>"Jeanette Cunningham" wrote:
>
>> Hi Sophia
>> this is a common error which you can trap, so that it doesn't show.
>> The error is telling that the unload of the form was cancelled.
>>
>> To trap that error, you need to get the error number for it. Next time you
>> run the form, write down the error number.
>>
>> Now put some error handling code something like this:
>>
>> Private Sub Form_Unload(Cancel As Integer)
>> On Error GoTo Err_Handler
>>
>> If SubfrmAssessment_Details_Admission.Form.RecordsetClone.RecordCount = 0
>> Then
>> intResponse = MsgBox("Enter an Admission Assessment", vbYesNo, "Admission
>> assessment is not done")
>>
>> If intResponse = vbYes Then
>> Cancel = true
>> End If
>> End If
>>
>> Exit_Handler:
>> Exit Sub
>>
>> Err_Handler:
>> If Err.Number = 2501 Then
>> Else
>> MsgBox Err.Number & " " & Err.Description
>> End If
>> End Sub
>>
>> 2501 is probably not the correct error number, replace it with the error
>> number you are getting for the error.
>> Now when the error occurs, it is trapped by the error handler instead of
>> appearing.


I think it could be a 2501 error, but it is probably coming
from the code that is trying to close the form.

How did you indicate that you wanted to close the form?
A button on the form, the X in the form title bar, or ... ?
If it was a button on the form, try trapping the error
there. If it was the title bar X, then the message is
supposed to appear so users know the window is still working
(try handling the error in the form's Error event??)

--
Marsh
MVP [MS Access]
Re: unload event "you canceled the previous operation" error
Sophia 12/30/2008 3:35:00 AM
Thank you to Marshall and Jeanette. The error resulted from using a "close"
button to close the form. If I used the "x", I didn't get the message.

The error was 3021.

"Marshall Barton" wrote:

[Quoted Text]
> Sophia wrote:
>
> >Jeanette: Thank you for the advise, but it isn't an error which has a
> >number, that I can find anyway. It is a message box that pops up, after the
> >user chooses "Yes" to the question, prior.
> >
> >Any suggestions?
> >
> >Sophia
> >
> >"Jeanette Cunningham" wrote:
> >
> >> Hi Sophia
> >> this is a common error which you can trap, so that it doesn't show.
> >> The error is telling that the unload of the form was cancelled.
> >>
> >> To trap that error, you need to get the error number for it. Next time you
> >> run the form, write down the error number.
> >>
> >> Now put some error handling code something like this:
> >>
> >> Private Sub Form_Unload(Cancel As Integer)
> >> On Error GoTo Err_Handler
> >>
> >> If SubfrmAssessment_Details_Admission.Form.RecordsetClone.RecordCount = 0
> >> Then
> >> intResponse = MsgBox("Enter an Admission Assessment", vbYesNo, "Admission
> >> assessment is not done")
> >>
> >> If intResponse = vbYes Then
> >> Cancel = true
> >> End If
> >> End If
> >>
> >> Exit_Handler:
> >> Exit Sub
> >>
> >> Err_Handler:
> >> If Err.Number = 2501 Then
> >> Else
> >> MsgBox Err.Number & " " & Err.Description
> >> End If
> >> End Sub
> >>
> >> 2501 is probably not the correct error number, replace it with the error
> >> number you are getting for the error.
> >> Now when the error occurs, it is trapped by the error handler instead of
> >> appearing.
>
>
> I think it could be a 2501 error, but it is probably coming
> from the code that is trying to close the form.
>
> How did you indicate that you wanted to close the form?
> A button on the form, the X in the form title bar, or ... ?
> If it was a button on the form, try trapping the error
> there. If it was the title bar X, then the message is
> supposed to appear so users know the window is still working
> (try handling the error in the form's Error event??)
>
> --
> Marsh
> MVP [MS Access]
>

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net