Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

ACC2000: How to Create a Graph Bound to Two Combo Boxes


View products that this article applies to.

This article was previously published under Q208335
Moderate: Requires basic macro, coding, and interoperability skills.

This article applies only to a Microsoft Access database (.mdb).

↑ Back to the top


Summary

This article describes how to create a graph that is bound to two combo boxes. You can control the data that is displayed in the graph by making selections from the combo boxes.

↑ Back to the top


More information

To create a chart that displays data selected by two combo boxes, follow these steps:

CAUTION: If you follow the steps in this example, you modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and follow these steps on a copy of the database.

  1. Start Microsoft Access and open the sample database Northwind.mdb.
  2. In the Database window, click Queries, and then click New to create a new query in Design view.
  3. In the Show Table dialog box, add the following tables, and then click Close.
    Orders
    Order Details
    Products
    Categories
  4. On the View menu, click Totals.
  5. Add the following fields to the query grid:
    Field: Freight
    Table: Orders
    Total: Sum

    Field: ProductName
    Table: Products
    Total: Group By

    Field: CategoryName
    Table: Categories
    Total: Group By

    Field: Year: CStr(Nz(Year([OrderDate])))
    Total: Group By
  6. Save the query as qryGraph and close it.
  7. In the Database window, click Forms, and then click New. In the New Form dialog box, click Chart Wizard, and then select qryGraph as the query which the object's data comes from. Click OK.
  8. Move the SumofFreight, ProductName, and CategoryName fields from the Available Fields box to the Fields for Chart box, and then click Next.
  9. In the next wizard dialog box, select the Column Chart type, and then click Next.
  10. In the next wizard dialog box, drag CategoryName to the Axis list (bottom of graph), and then drag ProductName to the Series list (right side of graph). Be sure that they replace the items that are already displayed in the Axis list and the Series list. Click Next.
  11. In the next wizard dialog box, type Freight Dollars by Category as the title of your chart, and then click Finish. The form opens in Form view.
  12. On the View menu, click Design View.
  13. On the View menu, click Form Header/Footer.
  14. Add two combo box controls to the Form Header section, and then assign the following properties to each combo box:
    Combo Box 1
    Name: SelectCat
    Row Source Type: Table/Query
    Row Source: Categories
    Column Count: 2
    Column Width: 0";1"
    Bound Column: 2

    Combo Box 2
    Name: SelectYear
    Row Source Type: Value List
    Row Source: 1996;1997;1998;1999
  15. Click the graph, and modify the following properties of the unbound object frame:
    Unbound Object Frame
    Name: FreightGraph
    Size Mode: Zoom
    Link Child Fields: CategoryName;Year
    Link Master Fields: SelectCat;SelectYear
    Width: 6.5"
    Height: 3.25"
  16. On the View menu, click Form View. Click different categories and years in each of the two combo boxes on the form.

    Note that the contents of the graph change. If you select 1999 as the year, the graph is blank because there is no data for that year.

↑ Back to the top


References

For more information about graph control properties, click Microsoft Access Help on the Help menu, type chart control properties (forms and reports) in the Office Assistant or the Answer Wizard, and then click Search to view the topics returned.

For more information about combo box properties, click Microsoft Access Help on the Help menu, type combo boxes: what they are and how they work in the Office Assistant or the Answer Wizard, and then click Search to view the topics returned.

↑ Back to the top


Keywords: KB208335, kbusage, kbhowto

↑ Back to the top

Article Info
Article ID : 208335
Revision : 2
Created on : 6/24/2004
Published on : 6/24/2004
Exists online : False
Views : 296