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

Last reviewed: September 2, 1997
Article ID: Q173334
The information in this article applies to:
  • Microsoft Access 97
  • Microsoft Office Developer Edition 97

SYMPTOMS

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

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.

  1. Start Microsoft Access 97.

  2. Open the sample database Northwind.mdb.

  3. Open a new, blank form in Design view.

  4. On the Insert menu, click ActiveX Control.

  5. In the Insert ActiveX Control dialog box, select Microsoft Common Dialog Control, version 5.0, and then click OK.

  6. Set the Name property of the Common Dialog control to "cmndlg" (without the quotation marks).

  7. Add a command button to the form, and set the Name property to Command0.

  8. 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
    
    

  9. Close and save the form as Form1.

  10. On the Tools menu, click Startup.

  11. In the Startup dialog box, select the Form1 form from the Display Form combo box, and then click OK.

  12. Close the database.

  13. 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.

  14. Install the application on a computer that has never had the retail version of Microsoft Access 97 installed.

  15. Start the application. When the startup form appears, click the command button.

  16. 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.

MORE INFORMATION

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

   acCmdCreateReplica
   acCmdEncryptDecryptDatabase
   acCmdImport
   acCmdLinkTables

Steps to Reproduce Behavior

  1. Start Microsoft Access 97.

  2. Open the sample database Northwind.mdb.

  3. Open a new, blank form in Design view.

  4. Create a command button, and set the OnClick property to the following event procedure:

           Sub Command0_Click()
              DoCmd.OutputTo acOutputTable, "Customers", acFormatTXT
           End Sub
    
    

  5. Open the form in Form view.

  6. Click the command button.

    Note that Microsoft Access prompts you for the location of the output file name.

  7. Choose a destination output file, and then click OK. This should successfully output the Customers table to the file you selected.

  8. Close and save the form as Form1.

  9. On the Tools menu, click Startup.

  10. In the Startup dialog box, select the Form1 form from the Display Form combo box, and then click OK.

  11. Close the database.

  12. 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.

  13. Install the application on a computer that has never had the retail version of Microsoft Access 97 installed.

  14. 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.

REFERENCES

For more information about the OutputTo method, search the Help Index for "OutputTo method," or ask the Microsoft Access 97 Office Assistant.

For more information about the RunCommand method, search the Help Index for "RunCommand method," or ask the Microsoft Access 97 Office Assistant.

For more information about the Common Dialog ActiveX control, search the Help Index for "CommonDialog control," or ask the Microsoft Access 97 Office Assistant.


Additional query words: prb ode
Keywords : OtpGnrl OtpProb
Version : WINDOWS:97
Platform : WINDOWS
Hardware : x86
Issue type : kbprb
Solution Type : kbworkaround


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 2, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.