Canceling Form Unload...

  • Thread starter Thread starter Manny
  • Start date Start date
M

Manny

Hi there,

I know I can cancel the unload event of a form with
DoCmd.CancelEvent. I just like to know, how can I can rid
of the "You cancel the previous Operation" Message I get
right after the cancel event?

Thanks for your inputs on this one.

Manny.
 
are you sure it's the Unload cancel that's causing the message? when i
tested it, i didn't get any sort of message - my form simply didn't close.
is anything else happening in the unload event? or perhaps in the Close
event - though i would think that event wouldn't fire until the Unload event
completes.
 
Manny said:
Hi there,

I know I can cancel the unload event of a form with
DoCmd.CancelEvent. I just like to know, how can I can rid
of the "You cancel the previous Operation" Message I get
right after the cancel event?

Thanks for your inputs on this one.

Manny.

Are you maybe closing the form using a code statement like

DoCmd.Close acForm, "FormName"

?

It wouldn't surprise me if you got an error on that line, if the form's
close was cancelled. If that's the problem, trap and ignore the error
at the point where you are closing the form:

On Error Resume Next

DoCmd.Close acForm, "FormName"

Select Case Err.Number
Case 0, 2501
' closed or cancelled -- do nothing
Case Else
MsgBox Err.Description, vbExclamation, "Error " & Err.Number
End Select
 
Back
Top