Microsoft KB Archive/210019

= ACC2000: How to Use Automation to Rotate a Three-Dimensional Chart =

Article ID: 210019

Article Last Modified on 6/29/2004

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q210019



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

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).



SUMMARY
This article shows you how to use Automation to rotate a chart created in Microsoft Graph.

NOTE: Only graphs of the three-dimensional type can be rotated.



MORE INFORMATION
You can use Automation to programmatically rotate a graph. By using the Rotation property, you can rotate a three-dimensional graph to change the viewpoint of a graph or to provide an animated effect.

To rotate a three-dimensional pie graph a full 360 degrees, 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 then open the sample database Northwind.mdb or the sample project NorthwindCS.adp. Open a new, blank form in Design view. On the Insert menu, click Chart. Click and drag a chart to the form. In the first dialog box of the Chart Wizard, under View, click Queries, and then select the Category Sales for 1997 query. Click Next. In the next dialog box, add the CategorySales and CategoryName fields to the Fields for Chart box. Click Next. In the next dialog box, click 3-D Pie Chart, and then click Finish. Your graph now appears on the form.</li> On the View menu, click Properties. Select the graph so that you are viewing the Graph object's properties. Set the Name property to MyGraph.</li> Add a command button to the form with the following properties:

Caption: Rotate Graph

OnClick: =RotateGraph

</li> Click the form, and then, on the View menu, click Code to view the form's module.</li>  Add the following code to the form's module: Function RotateGraph Dim OldRotation As Integer Dim NewRotation As Integer Dim GraphObj As Object Set GraphObj = Me![MyGraph].Object.Application.Chart

' Determine the initial rotation setting. OldRotation = GraphObj.Rotation

' Rotate graph from initial setting to 360 degrees. For NewRotation = OldRotation To 360 Step 12 GraphObj.Rotation = NewRotation If GraphObj.Rotation = 360 Then GraphObj.Rotation = 0 DoEvents DoCmd.RepaintObject Next End Function </li> Switch the form to Form view. Click the command button to make the graph rotate 360 degrees.</li></ol>

<div class="references_section">