ACC: Exporting to Fixed-Width Text File Left-Aligns NumbersID: Q98663
|
Moderate: Requires basic macro, coding, and interoperability skills.
When you export a table that contains a Number or a Currency field to a
fixed-width text file, the numbers in the table become left-aligned.
Because the numbers are being exported to a fixed-width text file, Microsoft Access pads zeroes to the right of the number until it meets the proper field width.
To make the numbers align with the decimal and pad zeros to the left
instead of to the right, you must first determine the maximum length of the
Number or Currency field. Use this number of zeros in the Format() function
below. Next, you must determine the number of decimal places that the field
in question uses. Use this value to determine how many zeros to place after
the decimal point in the Format() function below. Finally, create a query
based on the following Microsoft Access SQL statement:
SELECT DISTINCTROW
Format([MyNumber],"0000.00")
AS [Expr1]
INTO [MyNewTable]
FROM [MyOldTable];
Table: MyOldTable
-----------------
Field Name: MyNumber
Data Type: Currency
This behavior is by design.
Table: MyOldTable
-----------------
Field Name: MyNumber
Data Type: Currency
34.5
123.56
4578.90
34.5000
123.560
4578.90
For more information about aligning fields in a fixed-width text file,
please see the following articles in the Microsoft Knowledge Base:
Q150401 ACC: Exporting Right-Aligned Fields to a Text File (95/97)
Q148444 ACC: Exporting Right-Aligned Fields to a Text File (1.x,
2.0)
Additional query words: importing/exporting leading zeros
Keywords : kb3rdparty IsmTxtfx
Version : 1.0 1.1 2.0 7.0 97
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: March 23, 1999