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

Error Message for Exporting to Excel 1

Status
Not open for further replies.

Garridon

Programmer
Mar 2, 2000
718
US
I have a button on a switchboard which exports a report to Microsoft Excel.&nbsp;&nbsp;The code for it is:<br><br>Private Sub cmdExportOpen_Click()<br>On Error GoTo cmdExportOpen_Click_Err<br><br>&nbsp;&nbsp;&nbsp;&nbsp;' Sends rptOpenSuspenses to a Microsoft Excel file<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OutputTo acReport, &quot;rptOpenSuspenses&quot;, &quot;MicrosoftExcel(*.xls)&quot;, &quot;&quot;, False, &quot;&quot;<br><br>cmdExportOpen_Click_Exit:<br>&nbsp;&nbsp;&nbsp;&nbsp;Exit Sub<br><br>cmdExportOpen_Click_Err:<br>&nbsp;&nbsp;&nbsp;&nbsp;MsgBox Error$<br>&nbsp;&nbsp;&nbsp;&nbsp;Resume cmdExportOpen_Click_Exit<br><br>End Sub<br><br>This opens the OutputTo window, which displays the directory where the report is to be saved.&nbsp;&nbsp;But if I decide not to save the report at this time and click the Cancel button instead, I get a message stating that &quot;The OutputTo action was cancelled.&quot;&nbsp;&nbsp;I want to stop this message from popping up.&nbsp;&nbsp;I tried using DoCmd.SetWarnings False, but the message still comes up.&nbsp;&nbsp;What else can I try?<br><br>Thanks!<br> <p>Linda Adams<br><a href=mailto:Garridon@aol.com>Garridon@aol.com</a><br><a href= Adams Online</a><br>I'm a professional writer, published internationally.
 
I'm not familiar with that function, but when I know an error number I handle it like this; substituting appropriate error number and message:<br><br>Err_cmdPO_Click:<br>&nbsp;&nbsp;&nbsp;&nbsp;If Err.Number = 3075 Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MsgBox &quot;Enter a value in this field to display details.&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Resume Exit_cmdPO_Click<br>&nbsp;&nbsp;&nbsp;&nbsp;Else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MsgBox Err.Description<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Resume Exit_cmdPO_Click<br>&nbsp;&nbsp;&nbsp;&nbsp;End If
 
Thanks!&nbsp;&nbsp;This helped me come up with some code that did the trick.<br><br> <p>Linda Adams<br><a href=mailto:Garridon@aol.com>Garridon@aol.com</a><br><a href= Adams Online</a><br>I'm a professional writer, published internationally.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top