Microsoft KB Archive/154583

= ACC: How to Use Automation to Rotate a 3-Dimensional Chart =

Article ID: 154583

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 Q154583



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



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

This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to your version of the "Building Applications with Microsoft Access" manual.

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

NOTE: A demonstration of the technique used in this article can be seen in the sample file, Grphsm97.exe. For information about how to obtain this sample file, please see the following article in the Microsoft Knowledge Base:

186855 ACC97: Microsoft Access 97 Sample Graphs Available in Download Center



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.

The following example rotates a three-dimensional pie graph a full 360 degrees:  Open the sample database Northwind.mdb. 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 "Employee Sales By Country" query. Click Next. In the next dialog box, add the Country and SaleAmount fields to the Fields For Chart box. Click Next. In the next dialog box, choose 3-D Pie Chart. Click Finish. Your graph will appear 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: <pre class="fixed_text">       Command button --       Caption: Rotate Graph OnClick: =RotateGraph </li> 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. When prompted for a beginning and ending date, enter 1/1/94 and 1/1/95 respectively. Click the command button.</li></ol>

<div class="references_section">