Microsoft KB Archive/155757

= ACC: How to Create a Graph Bound to Two Combo Boxes (95/97) =

Article ID: 155757

Article Last Modified on 1/19/2007

-

APPLIES TO


 * Microsoft Access 95 Standard Edition
 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q155757



Moderate: Requires basic macro, coding, and interoperability skills.



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



MORE INFORMATION
 Open the sample database Northwind.mdb.  Create a new query in Design view, and add the following tables:

      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> Using the Chart Wizard, create a new form based on the qryGraph query.</li> In the "Which fields contain the data you want for the chart?" dialog box, add SumofFreight, ProductName, and CategoryName to the Fields for Chart column, and then click Next.</li> In the "What type of chart would you like?" dialog box, click the Column Chart, and then click Next.</li> In the "How do you want to lay out the data in your chart?" dialog box, drag CategoryName to the Axis (bottom of graph) and drag ProductName to the Series (right side of graph), and then click Next.</li> In the "What title would you like for your chart?" dialog box, type Freight Dollars by Category, and then click Finish. The form will open in Form view.</li> On the View menu, click Form Design.</li> On the View menu, click Form Header/Footer.</li>  Add two combo box controls to the Form Header section with the following properties:

<pre class="fixed_text">      Combo Box: Name: SelectCat RowSourceType: Table/Query RowSource: Categories ColumnCount: 2 ColumnWidth: 0";1" BoundColumn: 2

Combo Box: Name: SelectYear RowSourceType: Value List RowSource: 1993;1994;1995;1996 </li>  Click the graph, and modify the following properties of the unbound object frame:

<pre class="fixed_text">      Unbound Object Frame: Name: FreightGraph SizeMode: Zoom LinkChildFields: CategoryName;Year LinkMasterFields: SelectCat;SelectYear Width: 6.5"         Height: 3.25" </li> Switch the form to Form view. Click different categories and years in each of the two combo boxes on the form and note that the contents of the graph change.</li></ol>

<div class="references_section">