Cancel open event

  • Thread starter Thread starter Nelson
  • Start date Start date
N

Nelson

When I cancel a form's open event (DoCmd.DoCmd.CancelEvent or Cancel = -1),
I get a MsgBox stating "the open form action was cancelled". How do I keep
that message from popping up? (I tried 'On Error' trapping to no avail.)

TIA,
Nelson
 
In a Form or Standard module. NOT in the Report module.

Sub PrintReport()
On Error GoTo ErrHandler

' <Insert Code to open report>

ExitHere:
Exit Sub
ErrHandler:
Select Case Err.Number
Case 2501
' Do nothing, exit gracefully: Action cancelled (possibly by
Report_NoData event)
Resume ExitHere
Case Else
' <Insert MsgBox code or whatever you want to happen on any
*other* kind of error>
Resume ExitHere
End Select
End Sub
 
Thanks George!

I didn't consider that the calling form, not the called form was generating
the error.
Nelson
 
Back
Top