Unload event "you canceled the previous operation" error

S

Sophia

Hi: I am trying to advise the user that a subform is empty before they close
the main form. When "yes" is chosen, to not close the form, the form does
not close, but, I am getting a message " you canceled the previous
operation". On the Unload event, I have the following:

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
 
S

Stuart McCall

Sophia said:
Hi: I am trying to advise the user that a subform is empty before they
close
the main form. When "yes" is chosen, to not close the form, the form does
not close, but, I am getting a message " you canceled the previous
operation". On the Unload event, I have the following:

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

Replace:

DoCmd.CancelEvent

with

Cancel = True

Notice the boolean Cancel parameter in the Unload event procedure's
definition. At runtime, this is passed to the procedure by reference, which
means that any change to its value will be 'returned' to Access, which will
then prevent the form from closing.
 
S

Sophia

Hi Stuart: I have this post also on Dec 26th, since there was a problem with
the website and the message did not show up, so I posted it again.

I did try what you suggested, but then I receive the pop up " no current
record". Any other suggestions?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top