Microsoft KB Archive/198468

= ACC2000: How to Automate Changes to Properties of a Graph Axis =

Article ID: 198468

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q198468



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



SUMMARY
This article shows you how to use code to change the properties of a graph on a form. The example shows you how to change the Minimum and Maximum Scale, and the Minor and Major Unit properties of the Y-axis on a Microsoft Graph object embedded in a form.

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.



MORE INFORMATION
In the following example, you create a form with a graph, four text boxes, and a command button. You type the values for Minimum Scale, Maximum Scale, Minor Unit, and Major Unit in the text boxes, and then click the button to see the changes in the graph.  Open the sample database Northwind.mdb. Create a new form as follows:  Use the Chart Wizard to create a new form based on the Orders table. In the "Which fields contain the data you want for the chart?" dialog box, add OrderID and EmployeeID to the Fields For Chart box, and then click Next. In the "What type of chart would you like" dialog box, click Column Chart, and then click Next. In the "How do you want to lay out the data in your chart?" dialog box, drag OrderID to Data (at the upper-left of the graph). Drag EmployeeID to Axis (at the bottom of the graph). Leave Series blank, and then click Next.</li> In the "What title would you like for your chart" dialog box, type Orders by Employee, click "Modify the design of the form or the chart," and then click Finish.</li></ol> </li> When the form opens in Design view, set the Name property of the Graph object to GraphOrders.</li>  Add the following controls to the detail section of the form: <pre class="fixed_text">  Text Box: Name: MinScale Text Box: Name: MaxScale Text Box: Name: MinorUnit Text Box: Name: MajorUnit Command Button: Name: ChangeGraph Caption: Change Graph OnClick: [Event Procedure] </li>  Click the Build button next to the OnClick property of the command button and type the following code: Private Sub ChangeGraph_Click Me![GraphOrders].Axes(2).minimumscale= Me![MinScale] Me![GraphOrders].Axes(2).maximumscale= Me![MaxScale] Me![GraphOrders].Axes(2).minorunit= Me![MinorUnit] Me![GraphOrders].Axes(2).majorunit= Me![MajorUnit] End Sub </li> Save the form as frmOLEGraph and switch it to Form view.</li> Note the appearance of the graph. Type 1 in the MinScale box, 100 in the MaxScale box, 5 in the MinorUnit box, and 20.5 in the MajorUnit box.</li> Click the Change Graph button. Note that the Y-axis ranges from 1 to 100 in increments of 20.5.</li></ol>

<div class="references_section">