ACC: How to Use Automation to Change Border Properties for Chart

ID: Q154584


The information in this article applies to:
  • Microsoft Access versions 7.0, 97


SUMMARY

This article shows you how to use Automation to modify properties of the Border object in a Microsoft Graph object.

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.


MORE INFORMATION

You can use Automation to change the Border object properties of a Microsoft Graph chart. Through code, you change such properties as BorderColor, LineStyle, and Weight.

The following example steps you through creating a Microsoft Graph chart in a form, and then changes the chart's default border to a thick, red dashed line:

  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 Finish. Your graph will appear in the form.


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


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


  8. Command button:
    Caption: Add Border
    OnClick: =AddBorder()
  9. On the View menu, click Code to view the form's module.


  10. Add the following code to the form's module:


  11. 
           Function AddBorder()
              Dim GraphObj As Object
              Set GraphObj = Me![MyGraph].Object.Application.Chart
              GraphObj.ChartArea.Border.LineStyle = 4
              GraphObj.ChartArea.Border.Weight = 4
              GraphObj.ChartArea.Border.Color = 255
           End Function 
  12. Switch the form to Form view. When prompted for a beginning and ending date, enter "1/1/94" and "1/1/95" respectively (without the quotation marks). Click the command button to run the code and change the border type.



REFERENCES

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

Q128364 Microsoft Graph VBA Help File Available in Download Center
For more information about the Border object and modifying its color, line and weight, open the Microsoft Graph Help file (you must have the VBA_GRP.HLP Help file installed), and search on "Border Object," "RGB function," "LineStyle Property," and "Weight Property."

For more information about Automation, search the Help Index for "Automation," and "Automation with Microsoft Access," or ask the Microsoft Access 97 Office Assistant.

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:
Q148124 ACC95: OLE Automation Help File Available in Download Center

Additional query words:

Keywords : kbinterop kbtool IntpGrph
Version : WINDOWS:7.0,97
Platform : WINDOWS
Issue type : kbhowto


Last Reviewed: November 13, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.