ACC2000: How to Use Automation to Change Border Properties for a Chart (210017)



The information in this article applies to:

  • Microsoft Access 2000

This article was previously published under Q210017
Moderate: Requires basic macro, coding, and interoperability skills.

This article applies only to a Microsoft Access database (.mdb).

SUMMARY

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

MORE INFORMATION

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

To create a Microsoft Graph chart in a form, and then change the chart's default border to a thick, red, dashed line, follow these steps:
  1. Start Microsoft Access and open the sample database Northwind.mdb.
  2. In the Database window, click Forms under Objects, and then click New.
  3. In the New Form dialog box, click Chart Wizard, select Category Sales for 1997 as the query where the object's data comes from, and then click OK.
  4. In the next dialog box, add the CategoryName and CategorySales fields to the Fields for Chart box. Click Finish. Your graph appears in the form. Switch to Design view.
  5. 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.
  6. Add a command button to the form with the following properties:

    Caption: Add Border
    OnClick: =AddBorder()

  7. Click on the form, and then, on the View menu, click Code to view the form's module.
  8. Add the following code to the form's module:
    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 = 150
    End Function
    
    					
  9. On the View menu, click Form View. Click the command button to run the code and change the border type.

REFERENCES


For more information about the Border object and modifying its color, click Microsoft Graph Help on the Help menu, type border in the Office Assistant or the Answer Wizard, and then click Search to view the topics returned.

For more information about automation, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type understanding automation in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

For additional information about modifying graph objects using automation, click the article number below to view the article in the Microsoft Knowledge Base:

202147 How to Use Automation to Modify MS Graph Object


Modification Type:MajorLast Reviewed:6/28/2004
Keywords:kbhowto kbinterop KB210017