Microsoft KB Archive/208408

= ACC2000: Exporting to Text File Truncates to Two Decimals Places =

Article ID: 208408

Article Last Modified on 8/30/2002

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q208408



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



SYMPTOMS
If you have a table that contains a Number field with more than two decimal places, and you export the table to a text file, the decimal places are truncated to two positions.



Method 1
When you export the data, you can select Save Formatted in the Export Table dialog box.

Method2
Create a query with the fields that you want to export and then use the Format function. You can use the following function to specify the number of decimal places in the Number field. For example, if your field has four decimal places, the column in the query grid looks as follows:

Field: Format([fieldname],"##0.0000")

You can also use the CStr function to convert the field to text before you export. For example, the column in the query grid looks as follows:

Field: CStr([fieldname])



Steps to Reproduce the Behavior
 Open the sample database Northwind.mdb. Open the Suppliers table in Design View.  Add a field to the Suppliers table with the following properties:   Field Name: Cost Data Type: Number Field Size: Double Decimal Places: 4  Close, and then save the table. Open the Suppliers table in Datasheet view, and then scroll right until you see the Cost field. Type data in this field for several records, and then make sure that the data contains at least three decimal places.</li> Close the table, and then on the File menu, click Save.</li> In the Save As Type box, click Text Files, and then click Export.</li> When the Text Export Wizard appears, click Next two times, and then click Finish.

When the file has been exported, open the text file. Note that the Cost field is truncated to two decimal places.</li></ol>

<div class="references_section">