Microsoft KB Archive/208335

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

Article ID: 208335

Article Last Modified on 6/24/2004

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



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).



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.



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.

 Start Microsoft Access and open the sample database Northwind.mdb. In the Database window, click Queries, and then click New to create a new query in Design view. In the Show Table dialog box, add the following tables, and then click Close.

Orders

Order Details

Products

Categories

 On the View menu, click Totals. 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

 Save the query as qryGraph and close it.</li> 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.</li> Move the SumofFreight, ProductName, and CategoryName fields from the Available Fields box to the Fields for Chart box, and then click Next.</li> In the next wizard dialog box, select the Column Chart type, and then click Next.</li> 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.</li> 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.</li> On the View menu, click Design View.</li> On the View menu, click Form Header/Footer.</li> 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

</li> 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"

</li> 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.</li></ol>

<div class="references_section">