Microsoft Knowledge Base Email Alertz

KBAlertz.com: (154581) - This article shows you how to use Automation to add, remove, and set trend lines on a Microsoft Graph object. This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the...

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]

Search KbAlertz

Advanced Search

Webmasters
Put kbAlertz on your website.
[ Click Here for more! ]





ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
The ad says 3 - but KBAlertz referrals get
** SIX MONTHS FREE **


Bug Tracking Software
For bug tracking software or defect tracking software or issue tracking software, visit Axosoft.


Community Site



We Send hundreds of thousands of emails using ASP.NET Email



Expert Web Design & Graphic Design
Design44.com

ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
The ad says 3 - but KBAlertz referrals get
** SIX MONTHS FREE **




Mentioned In








Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks




Article ID: 154581 - Last Review: January 19, 2007 - Revision: 3.3

ACC: How to Use Automation to Set Graph Trend Lines

This article was previously published under Q154581
Advanced: Requires expert coding, interoperability, and multiuser skills.

On This Page

SUMMARY

This article shows you how to use Automation to add, remove, and set trend lines on 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.

NOTE: A demonstration of the technique used in this article can be seen in the sample file, Grphsm97.exe. For information about how to obtain this sample file, please see the following article in the Microsoft Knowledge Base:
186855  (http://kbalertz.com/Feedback.aspx?kbNumber=186855/EN-US/ ) ACC97: Microsoft Access 97 Sample Graphs Available in Download Center

MORE INFORMATION

Different types of trend measurements exist. You can use the Type property to select a specific trend to use in your graph. You can also use the Add method to add trend lines to your graph, or use the Delete method to remove trend lines. Trend lines only apply to two-dimensional graphs of type "Bar," "Column," "Line," and "Scatter." The following examples use a bar graph.

Example - Add a Trendline and set its Type

The following example adds a trend line to the first series of data and sets it to be of type Polynomial:
  1. Open the sample database Northwind.mdb.
  2. Create a new form not based on any table or query in Design view.
  3. On the Insert menu, click Chart, and then click in the detail section of the form to start the Chart Wizard.
  4. In the "Which table or query would you like to use to create your chart?" dialog box, click Queries, and then select the Employee Sales By Country query. Click Next.
  5. In the "Which fields contain the data you want for the chart?" 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:
    Command button:
    Caption: Add Trend Line
    OnClick: =AddTrendLine()
  8. On the View menu, click Code to view the form's module.
  9. Add the following code to the form's module:
           Function AddTrendLine()
             Dim GraphObj As Object
             Set GraphObj = Me![MyGraph].Object.Application.Chart
             GraphObj.SeriesCollection(1).TrendLines.Add
             GraphObj.SeriesCollection(1).TrendLines(1).Type = 3
           End Function
    					
  10. 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 Add Trend Line button. Note the trend line added to the chart.

Example - Remove a Data Series Trendline

The following example removes the trend line from the first series of data being graphed in the earlier example:

  1. Use the form created in the first example, and add another command button with the following properties:
    Command button:
    Caption: Remove Trend Line
    OnClick: =RemoveTrendLine()
  2. On the View menu, click Code to view the form's module.
  3. Add the following code to the form's module:
          Function RemoveTrendLine()
             Dim GraphObj As Object
             Set GraphObj = Me![MyGraph].Object.Application.Chart
             GraphObj.SeriesCollection(1).TrendLines(1).Delete
          End Function
    					
  4. Switch the form to Form view. When prompted for a beginning and ending date, enter 1/1/94 and 1/1/95 respectively.
  5. Click the Add Trend Line button to add the trend line to the chart.
  6. Click the Remove Trend Line button. Note the trend line is removed from the chart.

REFERENCES

For information about obtaining a Help file for Microsoft Graph, please see the following article in the Microsoft Knowledge Base:
128364  (http://kbalertz.com/Feedback.aspx?kbNumber=128364/EN-US/ ) Microsoft Graph VBA Help File Available in Download Center
For more information about trend lines, search the Help Index in the Microsoft Graph VBA Help file for "Trendline object."

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

For information about obtaining a Help file with examples of Automation between Microsoft Access and Microsoft Graph, please see the following article in the Microsoft Knowledge Base:
148124  (http://kbalertz.com/Feedback.aspx?kbNumber=148124/EN-US/ ) ACC95: OLE Automation Help File Available in Download Center

APPLIES TO
  • Microsoft Access 95 Standard Edition
  • Microsoft Access 97 Standard Edition
Keywords: 
kbhowto kbinterop kbprogramming KB154581
Retired KB ArticleRetired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate

Be the first to leave feedback, to help others about this knowledge base article.

(Optional) Name

(Optional) Public URL Or Email

Comments
No HTML -- Text Only Please