ACC97: Incorrect Records in Query Exported to File

Last reviewed: March 3, 1998
Article ID: Q181329
The information in this article applies to:
  • Microsoft Access 97

SYMPTOMS

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

If you modify an existing query and then export it to another file format without saving it, the expected data may not appear in the resulting file. For example, this behavior can occur when you export a query to a text file (*.txt), to Microsoft Excel 97 (*.xls), or to a dBASE file format (*.dbf).

CAUSE

When you export a query, Microsoft Access uses the SQL property of the QueryDef object to determine which records and fields should be exported. Modifications that you make to a query exist in a temporary object until you save the query. At that time, the SQL property of the QueryDef object is updated.

RESOLUTION

Save the query before you export it to another file format.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Start Microsoft Access and open the sample database Northwind.mdb.

  2. Create the following query based on the Shippers table:

       Query: qryExportTest
       --------------------
       Type: Select Query

       Field: ShipperID
          Table: Shippers
       Field: CompanyName
          Table: Shippers
       Field: Phone
          Table: Shippers

  3. Save the query as qryExportTest.

  4. On the Query menu, click Run. Note that the query returns three
     records.

  5. On the View menu, click Design View and add the following criteria to
     the ShipperID field:

       <> 3

  6. Run the query without saving it. Note that the query returns two
     records.

  7. On the File menu, click Save As/Export.

  8. In the Save As dialog box, click "To an External File or Database,"
     and then click OK.

  9. In the Save In dialog box, click Microsoft Excel 97(*.xls) in the Save
     As Type list.

 10. In the File Name box, type "qryExportTest.xls" (without the quotation
     marks), and then click Export.

 11. Start Microsoft Excel and open qryExportTest.xls. Note that in
     addition to the column names, the spreadsheet contains three records
     instead of the two records returned by the unsaved query.

REFERENCES

For more information about exporting, search the Help Index for "exporting data" and display the topic "Export data to another database or file format," or ask the Microsoft Access 97 Office Assistant.


Additional query words: prb results missing not there
Keywords : IsmExl5 IntpOthr kbdta
Version : WINDOWS:97
Platform : WINDOWS
Hardware : x86
Issue type : kbprb


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: March 3, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.