Results 1 to 4 of 4
  1. #1
    Lounger
    Join Date
    Aug 2006
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Export query as .txt error (Access XP)

    I am using the "Export Text Wizard" from a query to load the results into a tab delimited text file.

    When I get to the final screen in the wizard, and type in the filename in the "Export to file:" text box, and press Finish I get the error:
    "The Microsoft Jet Database Engine could not find the object '<filename>'. Make sure that the object exists and that you spell its name and path correctly."
    Then the message,
    "An error occurred when trying to export data from the table '<queryname>'. The data was not exported."

    I have tried changing the export file specifications/delimiters, the query name, the filename etc.. and nothing seems to by pass these errors. How do I create the text file from my query?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Export query as .txt error (Access XP)

    Make sure that you specift a filename with an extension of .txt, .csv, .tab or .asc. Any other (or no) extension will cause the error message you report.

  3. #3
    Lounger
    Join Date
    Aug 2006
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Export query as .txt error (Access XP)

    Thanks Hans. That fixed it.

    I was wondering how to export the query results to a text file using VBA?
    Also, using VBA, is it possible to nominate the Import/Export specification that I have already defined?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Export query as .txt error (Access XP)

    You can use DoCmd.TransferText to export a query to a text file. Here is an example:
    <code>
    DoCmd.TransferText TransferType:=acExportFixed, _
    SpecificationName:="MyExportSpec", TableName:="qrySomething", _
    FileName:="C:TestExport.txt", HasFieldNames:=True
    </code>
    To export to a fixed-width text file, use acExportFixed, and to export to a file with a field delimiter such as a tab or comma, use acExportDelim. The delimiter is specified in the export specification.

    Type the word TransferText in a module or in the Immediate window and press F1 to get further help on this method.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •