Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cancellation of an event

Status
Not open for further replies.

Dreamwalker

Programmer
Apr 30, 2002
43
0
0
US
Ok here is my problem :)

On the Report_Click I opened my report
Docmd.OpenReport ReportName , acpreview

It runs Report_open

If OpenEvent = False
Cancel = True
End if

Function OpenEvent as Boolean
If my data is correct everything will be fine

If my data is incorrect it runs Cancel = true then goes back to Report_Click ... and gives an error message about this event has been cancelled ... Im wondering how to remove this error ... I only want to cancel and continue everything w/o errors ...

Thanks for any help

Vince aka Dreamwalker
 
I assume you are referring to error 2501? What you need to do is handle the error in your error handler on the on click event. Now understand I use a custom event handler where I call an event. This will give you the idea though.

Private Sub Report_Click ()

On Error GoTo DefaultHandler

If OpenEvent = False
Cancel = True
End if

SubExit:
Exit Sub

DefaultHandler:
'* If we run into an error display our form and create an
'* errorlog.txt file. If no error's are detected exit the
'* program.

Select Case Err.Number
'* Handle errors here.
'* supress cancel error.
Case 2501

Case Else
Call ShowError(Me.Name, "cmdClose_Click", Err.Number, _
Err.Description)
End Select
Resume SubExit

End Sub Life's a journey enjoy the ride...

jazzz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top