Microsoft KB Archive/210344

= ACC2000: How to Use Automation to Change a Graph's Type =

Article ID: 210344

Article Last Modified on 7/15/2004

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q210344



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

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



SUMMARY
This article shows you how to use Automation to dynamically change a chart's type. For example, you can use this method to change a bar chart to a column chart as you print a report or view records in a form.



MORE INFORMATION
To use Automation to change a chart's type at run time, follow these steps:  Start Microsoft Access and open the sample database Northwind.mdb. Create a new form based on the Ten Most Expensive Products query. On the Insert menu, click Chart, and then insert a new chart in the form. In the Which Table or Query Would You Like to Use to Create Your Chart box, select the Ten Most Expensive Products query, and then click Next. Select the two available fields and click Finish. Set the embedded graph's Name property to MyGraph.  Add an option group to the form, and then add the following six option buttons to the option group: <pre class="fixed_text">  Name: Area OptionValue: 1 Name: Bar OptionValue: 2 Name: Column OptionValue: 3 Name: 3D_Area OptionValue: -4098 Name: 3D_Bar OptionValue: -4099 Name: 3D_Column OptionValue: -4100 </li>  Set the option group's Name property to Graph_Type and the option group's AfterUpdate property to the following event procedure: Private Sub Graph_Type_AfterUpdate Me![MyGraph].Object.Application.Chart.Type = Int(Me![Graph_Type]) End Sub </li> View the form in Form view.</li> Click the various toggle buttons.

Note that the chart changes to match your selection.</li></ol>

<div class="references_section">