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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with DoCmd.OutputTo

Status
Not open for further replies.

legs00

Programmer
Oct 17, 2001
36
CA
Hi Well I am outputting records to an excel spreadsheet and I am using "DoCmd.OutputTo acOutputQuery". Now when I press the cancel button of that form I get an error:

Run-Time Error: "2501"
the OutputTo action was cancelled

What I would like to know is how to code so that if the cancel button of that OutputTo form is clicked then it will cancel that event or exit that form.
Thank you
Legs
 
Try this:

=====
Your Sub or Function()
On Error GoTo HandleError

..... Your Code Here

HandleError_Exit:
Exit Sub

HandleError:
If Err.Number = 2051 Then
Resume HandleError_Exit
Else
MsgBox Err.Number & ": " & Err.Description
Resume HandleError_Exit
End If
End Sub
Jim Lunde
compugeeks@hotmail.com
Custom Application Development
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top