When a chart is created, the nature of the chart and/or the type of
grouping may require a temporary modification of the data that is sent to
the chart.
This modification takes place in the SQL statement that is generated for
the chart by the Chart Wizard. In the example cited for this article, a
Date field is converted to an integer number using the
Year() function. Because this data is no longer a Date data type, it cannot be formatted using the available Date formats.
When a chart is created using the Chart Wizard, a SQL statement is built.
This statement is placed in the
RowSource property of the chart object. Each time the form or report in which the chart resides is refreshed, the SQL statement is re-run, and the results are sent to Microsoft Graph.
How to Change the Format of the Labels in a Chart
To change the format of the labels in a chart, follow these steps:
- Open the sample database Northwind.mdb.
- On the Insert menu, click Form.
- In the New Form dialog box, click Chart Wizard, select the Orders table in the Choose the table....comes from list box, and then click OK.
- In the Chart Wizard dialog box, under Available Fields, select the OrderDate field, and then add it to the Fields for Chart list.
- Repeat step 4 for the Freight field, and then click the Next button two times to accept the defaults.
- Double-click the X-Axis label OrderDate by month.
- In the Group dialog box, click Year, and then click OK.
- Click Finish. Note that the labels for the axes are 1996, 1997, 1998, and 2000.
Changing the Label Format
- On the View menu, click Design View.
- Select the chart. If the property sheet is not displayed, on the View menu, click Properties.
- Right-click the RowSource property, and then click Build on the shortcut menu.
- Change the Year([OrderDate]) field to Format([OrderDate],"YY").
- Run the query to verify that the years in the OrderDate column are formatted as follows: 96, 97, 98, 00.
- Close the query, and then save the changes.
- Switch the form to Form view. Note that the labels of the axes are now formatted as: 96, 97, 98, 00.