Moderate: Requires basic macro, coding, and interoperability skills.
For a Microsoft Access 2000 version of this article, see
201115.
RESOLUTION
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];
For this example, the SQL statement assumes that you have the following
table:
Table: MyOldTable
-----------------
Field Name: MyNumber
Data Type: Currency
The SQL statement also assumes that the longest value in the MyNumber field is 7 characters (including the decimal point and decimal places) and that each value has two decimal places. When you type this Microsoft Access SQL statement in the SQL window in the query design grid, it creates a new table named MyNewTable with the MyNumber field padded to the left with zeros.
When you use this Microsoft Access SQL statement in a query, the data from
MyOldTable is formatted with decimal justification and placed in a new
table called MyNewTable.