ACC: How to Rotate a 3-Dimensional Chart Using Automation

Last reviewed: August 28, 1997
Article ID: Q154583
The information in this article applies to:
  • Microsoft Access versions 7.0, 97

SUMMARY

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

This article demonstrates 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.

MORE INFORMATION

Through Automation, it is possible to programmatically rotate a graph. Using the Rotation property, a three-dimensional graph can be rotated to change the viewpoint of a graph or to provide an animated effect.

Example - Rotate a 3-Dimensional Graph

The following example will rotate a three-dimensional pie graph a full 360 degrees:

  1. Open the sample database Northwind.mdb.

  2. Open a new, blank form in design view.

  3. On the Insert menu, click Chart. Click and drag a chart to the form.

  4. In the first dialog box of the Chart Wizard, under view, click Queries, and then select the "Employee Sales By Country" query. Click Next.

  5. In the next dialog box, add the Country and SaleAmount fields to the Fields For Chart box. Click Next.

  6. In the next dialog box, choose 3-D Pie Chart. Click Finish. Your graph will appear on the form.

  7. 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.

  8. Add a command button to the form with the following properties:

          Command button
          --------------
          Caption: Rotate Graph
          OnClick: =RotateGraph()
    

  9. On the View menu, click Code to view the form's module.

  10. 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
    

  11. 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.
    

REFERENCES

For more information about Microsoft Graph, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q128364
   TITLE     : Microsoft Graph VBA Help File Available on MSL

For more information about the Type property and for a listing of chart types and their constants, open the Microsoft Graph help file (you must have the VBA_GRP.HLP help file installed), and search on "Rotation property."

For more information about Automation, search the Help Index for "Automation."

For more examples of Automation between Microsoft Access and Microsoft Graph, obtain the Automation Help File as described in the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q148124
   TITLE:    : OLE Automation Help File (95) Available on MSL
Keywords          : AutoGrph kbinterop kbtool PgmObj IntpGrph
Technology        : kbole
Version           : 7.0 97
Platform          : WINDOWS
Hardware          : x86
Issue type        : kbhowto


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: August 28, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.