Microsoft KB Archive/210017

= ACC2000: How to Use Automation to Change Border Properties for a Chart =

Article ID: 210017

Article Last Modified on 6/28/2004

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



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:  Start Microsoft Access and open the sample database Northwind.mdb. In the Database window, click Forms under Objects, and then click New. 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. 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. 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. Add a command button to the form with the following properties:

Caption: Add Border

OnClick: =AddBorder

</li> Click on 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 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

</li> On the View menu, click Form View. Click the command button to run the code and change the border type.</li></ol>

<div class="references_section">