Lesson 4.9. Formatting Number, Currency, and Date/Time Fields
Figure 4-12. The Format property
A field's Format property changes how information appears in the field, not how the data is actually stored in the field. For example, a date field could be formatted to display the same value as 6/10/2000; Saturday, June 10, 2000; or 10-Jun-00. Each field type has its own set of formats. For example, number fields have a different set of formats than date/time or text fields.
This lesson explains how to format number, currency and . There are two ways to format a number, currency and date/time field:
Hopefully, the ready-made formats listed in Table 4-4 will be all you will ever need to format your fields. This lesson explains how to format number, currency, and date/time fields by selecting a ready-made format.
Double-click the tblCustomerTours table.
Let's take a look at how the number and date fields in this table are currently formatted. Notice that the Cost has two decimal places and that the displays its dates in the 1/1/2000 format.
Note: If you haven't installed any Year 2000 updates, such as the Microsoft Office 97 Service Pack 2, your dates may be displayed in 1/1/00 format. If this is the case, you should visit the Microsoft Office Update Web site, located at www.officeupdate.com, and download Microsoft Office 97 Service Pack 2.
Switch to Design view by clicking the View button on the toolbar.
Now you can change the formats of the fields in the tblCustomerTours table.
Click the Date field and click the Format box in the Field Properties section.
A list arrow appears in the Format box. You can format this field the easy way by clicking the arrow to select from a list of ready-made number formats, as shown in Figure 4-12.
Click the list arrow and select Medium Date.
The Date field will now display its dates in 1-Jan-00 format instead of the 1/1/2000 format.
You can also specify how many decimal places you want numbers in a field to display. To change the number of decimal places in a , you enter the number of decimal places you want displayed in the Decimal Places box.
Click the Cost field, click the Decimal Places list arrow, and select 0.
Now the will not display any decimal places, and Access will round any decimals equal to or greater than five to the next number.
Note: Depending on the field property, the Property Update Options button may appear next to the Cost field. By default, the only affects the number of decimal places that are displayednot how many decimal places are stored. If you want to change this, click the Property Update Options button and select "Update Decimal Places everywhere Cost is used" from the menu.
You'll need to save the table before you can view your new Format settings.
Note: The Decimal Places property setting has no effect if the Format property is blank or is set to General Number.
Click the Save button on the toolbar to save your changes.
Now let's see how the fields look with their new .
Switch to Datasheet view by clicking the View button on the toolbar.
Notice the Date field now displays dates in a 1-Jan-00 format and the Cost field no longer has any decimal places.
Below you will find a list of ready-made number, currency, and date/time that you can choose from. These standard should be all you'll ever needif not, take a look at Lesson 4-10: Formatting Number, Currency, and Date/Time Fields by Hand.
Table 4-4. Number, Currency, and Date/Time Formats
6/10/2000 6:35:21 PM
Saturday, June 10, 2000
TO FORMAT NUMBER AND CURRENCY FIELDS:
MAKE SURE THE TABLE IS DISPLAYED IN DESIGN VIEW AND CLICK THE FIELD YOU WANT TO FORMAT.
CLICK THE FORMAT BOX IN THE FIELD PROPERTIES SECTION.
CLICK THE LIST ARROW AND SELECT A NUMBER FORMAT.
TO CHANGE THE NUMBER OF DECIMAL PLACES:
MAKE SURE THE TABLE IS DISPLAYED IN DESIGN VIEW AND THEN CLICK THE FIELD YOU WANT TO FORMAT.
CLICK THE DECIMAL PLACES BOX IN THE FIELD PROPERTIES SECTION.
CLICK THE LIST ARROW AND SELECT THE NUMBER OF DECIMAL PLACES YOU WANT TO DISPLAY.