Microsoft KB Archive/154584

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

Article ID: 154584

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 Q154584





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

Command button:

Caption: Add Border

OnClick: =AddBorder

</li> 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 = 255 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 (without the quotation marks). Click the command button to run the code and change the border type.</li></ol>

<div class="references_section">