Microsoft KB Archive/173334

= ODE97: OutputTo Action Was Canceled Error in Run-time App =

Article ID: 173334

Article Last Modified on 1/20/2007

-

APPLIES TO


 * Microsoft Access 97 Standard Edition
 * Microsoft Office 97 Developer Edition

-



This article was previously published under Q173334



Moderate: Requires basic macro, coding, and interoperability skills.



SYMPTOMS
When you use the OutputTo method or RunCommand method in a Microsoft Access 97 run-time application, you may receive the following error message:

The OutputTo action was canceled.

  -or-

The RunCommand action was canceled.

This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to the "Building Applications with Microsoft Access 97" manual.



CAUSE
Your computer has only a run-time version of Microsoft Access 97 installed, and you are using an action or method that prompts the user for an input or output file name. For example, if you use the OutputTo method and leave the Outputfile argument blank, Microsoft Access prompts you for an output file name.



RESOLUTION
Explicitly supply the file name so that Microsoft Access does not have to prompt the user for one. If you want to prompt the user for a file name, you can use the ShowOpen or ShowSave methods of the Common Dialog ActiveX control.

The following steps demonstrate how to use the Common Dialog ActiveX control to prompt the user for an output file name and type, and then how to supply it to the OutputTo method.

 Start Microsoft Access 97. Open the sample database Northwind.mdb. Open a new, blank form in Design view. On the Insert menu, click ActiveX Control. In the Insert ActiveX Control dialog box, select Microsoft Common Dialog Control, version 5.0, and then click OK.</li> Set the Name property of the Common Dialog control to cmndlg .</li> Add a command button to the form, and set the Name property to Command0.</li>  Set the command button's OnClick property to the following event procedure:

Private Sub Command0_Click Dim oCmnDlg As CommonDialog Dim strFormat As String Dim strFileName As String Set oCmnDlg = Me!cmndlg.Object On Error GoTo Export_Err With oCmnDlg ' Clear the file name before prompting. .FileName = "" ' Prompt the user if the file already exists. .flags = cdlOFNOverwritePrompt + cdlOFNHideReadOnly ' Determine if the cancel button was pressed. .CancelError = True

.Filter = _ "MS-DOS Text (*.txt)|*.txt|Rich Text Format (*.rtf)|*.rtf" _ & "|Microsoft Excel (*.xls)|*.xls"

.FilterIndex = 1

' Default the initial directory to "C:\My Documents". .InitDir = "C:\My Documents" .ShowSave

' Determine what file type was selected; then save the ' file in that format. Select Case .FilterIndex Case 1 ' MS-DOS Text Format. strFormat = acFormatTXT

Case 2 ' Rich Text Format. strFormat = acFormatRTF

Case 3 ' Microsoft Excel Format. strFormat = acFormatXLS End Select strFileName = .FileName End With DoCmd.OutputTo acOutputTable, "Customers", _ strFormat, strFileName Exit Sub

Export_Exit: Exit Sub

Export_Err: ' Check to see if the cancel button was pressed. If Err.Number = 32755 Then Resume Export_Exit Else MsgBox Err.Number & ",   " & Err.Description End If         Resume Export_Exit End Sub </li> Close and save the form as Form1.</li> On the Tools menu, click Startup.</li> In the Startup dialog box, select the Form1 form from the Display Form combo box, and then click OK.</li> Close the database.</li> Use the ODE Setup Wizard to create a new set of disk images for the application. Add Northwind.mdb and Comdlg32.ocx to the list of files to distribute with the application. Select Northwind.mdb as the application's main file, and create a shortcut that uses the Run-time option to open Northwind.mdb.</li> Install the application on a computer that has never had the retail version of Microsoft Access 97 installed.</li> Start the application. When the startup form appears, click the command button.</li> Select an output file name, and a file type from the Save As Type list, and then click Save.

Note that the Customers table is saved to the file name and type that you selected in the Common Dialog ActiveX control.</li></ol>

<div class="moreinformation_section">

MORE INFORMATION
Using the following arguments of the RunCommand method result in a prompt for an input or output file name:

<pre class="fixed_text">  acCmdCreateReplica acCmdEncryptDecryptDatabase acCmdImport acCmdLinkTables

Steps to Reproduce Behavior
<ol> Start Microsoft Access 97.</li> Open the sample database Northwind.mdb.</li> Open a new, blank form in Design view.</li>  Create a command button, and set the OnClick property to the following event procedure:

Sub Command0_Click DoCmd.OutputTo acOutputTable, "Customers", acFormatTXT End Sub </li> Open the form in Form view.</li> <li>Click the command button.

Note that Microsoft Access prompts you for the location of the output file name.</li> <li>Choose a destination output file, and then click OK. This should successfully output the Customers table to the file you selected.</li> <li>Close and save the form as Form1.</li> <li>On the Tools menu, click Startup.</li> <li>In the Startup dialog box, select the Form1 form from the Display Form combo box, and then click OK.</li> <li>Close the database.</li> <li>Use the Setup Wizard to create disk images for the Northwind database. Be sure to select Northwind.mdb as the application's main file, and create a shortcut that uses the Run-time option to open Northwind.mdb.</li> <li>Install the application on a computer that has never had the retail version of Microsoft Access 97 installed.</li> <li>Start the application. When the startup form is displayed, click the command button.

Note that you receive the message "The OutputTo action was canceled," and then the application terminates.</li></ol>

<div class="references_section">