Help and Support
 

powered byLive Search

ACC: How to Change the Order of Columns in a Chart (95/97)

Retired KB ArticleThis article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
Article ID:141235
Last Review:January 19, 2007
Revision:3.1
This article was previously published under Q141235
On This Page

SUMMARY

Advanced: Requires expert coding, interoperability, and multiuser skills.

By default, a chart sorts the X-axis fields in alphabetical or numeric order. This article describes two methods you can use to sort the X-axis fields in a different order.

NOTE: A demonstration of the technique used in this article can be seen in the sample file, Grphsm97.exe. For information about how to obtain this sample file, please see the following article in the Microsoft Knowledge Base:

186855 (http://support.microsoft.com/kb/186855/EN-US/) ACC97: Microsoft Access 97 Sample Graphs Available in Download Center

Back to the top

MORE INFORMATION

There are two methods you can use to change the ordering of fields in a chart. The first way is to add an ORDER BY clause to the SQL statement in the chart's RowSource property. The second way is to create a query that orders the fields the way you want them, and then to use the query for the chart's RowSource property.

Back to the top

How to Create a Sample Chart

To create a chart, follow these steps:
1.Open the sample database Northwind.mdb.
2.Create a new, blank form not based on any table or query.
3.On the Insert menu, click Chart, and then click in the Detail section of the form where you want the chart to appear.
4.In the Chart Wizard dialog box, select the Sales By Category query as the data source for the chart, and then click Next.
5.Add the CategoryName and ProductSales fields to the Fields For Chart box, and then click Finish.
6.View the form in Form view. Note that the CategoryName records are listed in alphabetical order.

Back to the top

How to Change the Chart's Sorting Order

Back to the top

Method 1

The following example demonstrates how to add an Order By clause to the SQL statement in a Chart's RowSource property:
1.Open the form that you created in the "How to Create a Sample Chart" section in Design view.
2.Select the chart.
3.On the View menu, click Properties.
4.Select the RowSource property of the chart, and then press SHIFT+F2 to zoom in on the window. Note that the RowSource property's Select statement reads as follows:

SELECT [CategoryName],Sum([ProductSales]) AS [SumOfProductSales] FROM [Sales by Category] GROUP BY [CategoryName];
5.Type Order By SUM([ProductSales]) desc before the semicolon at the end of the SQL statement so that the SQL statement reads as follows:

SELECT [CategoryName],Sum([ProductSales]) AS SumOfProductSales] FROM [Sales by Category] GROUP BY [CategoryName] Order By SUM([ProductSales]) desc;
6.Click OK.
7.View the form in Form view. Note that the CategoryName records are now listed in descending order of sales.

Back to the top

Method 2

The following example describes how to create and use a query for the chart's RowSource property:
1.Re-create the form with a chart that you created in the "How to Create a Sample Chart" section.
2.Select the Chart.
3.On the View menu, click Properties.
4.Using the right mouse button, click the RowSource property, and then click Build.
5.In the SQL Statement: Query Builder window, set the sort order for the ProductSales field to Descending.
6.Close the SQL Statement: Query Builder window and save the changes.
7.View the form in Form view. Note that the CategoryName records are listed in descending order of sales.

Back to the top

REFERENCES

For more information about ordering fields, search for "ORDER BY clause" using the Microsoft Access 97 Help Index.

For more information about this topic in earlier versions of Microsoft Access, see the following article in the Microsoft Knowledge Base:

109315 (http://support.microsoft.com/kb/109315/EN-US/) ACC: How to Change the Order of Columns in a Graph (1.x, 2.0)

Back to the top


APPLIES TO
Microsoft Access 95 Standard Edition
Microsoft Access 97 Standard Edition

Back to the top

Keywords: 
kbhowto KB141235

Back to the top

Article Translations

 

Other Support Options

  • Need More Help?
    Contact a Support professional by Email, Online or Phone.
  • Customer Service
    For non-technical assistance with product purchases, subscriptions, online services, events, training courses, corporate sales, piracy issues, and more.
  • Newsgroups
    Pose a question to other users. Discussion groups and Forums about specific Microsoft products, technologies, and services.