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

Cancelling OutputTo gets error message.

Status
Not open for further replies.

juschuma

Programmer
Oct 23, 2002
18
0
0
US
I have the following command in my code:

DoCmd.OutputTo acOutputForm, , acFormatXLS

It allows me to export the forms data to Excel. A standard Microsoft window pops up with the directories, so I can save the file.

However, if I "Cancel" at that time, my original form returns an error message.

"Run Time error 2501 - The OutputTo action was cancelled"

Is there a way to error check this and prevent this message from occuring.

 
Easy to put some error handling in here..:

Code:
On Error goto Click_Err_Handle

DoCmd.OutputTo acOutputForm, , acFormatXLS

Click_Err_Handle:
If Err.Number = 2501 Then
Exit Sub 'or function
Else
End If

HTH's

SImon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top