ACC2000: How to Automate Changes to Properties of a Graph Axis
ID: Q198468
|
The information in this article applies to:
Advanced: Requires expert coding, interoperability, and multiuser skills.
SUMMARY
This article shows you how to use code to change the properties of a graph
on a form. The example shows you how to change the Minimum and Maximum
Scale, and the Minor and Major Unit properties of the Y-axis on a Microsoft
Graph object embedded in a form.
Microsoft provides programming examples for illustration only, without warranty
either expressed or implied, including, but not limited to, the implied warranties of
merchantability and/or fitness for a particular purpose. This article assumes that you
are familiar with the programming language being demonstrated and the tools used to
create and debug procedures. Microsoft support professionals can help explain the functionality
of a particular procedure, but they will not modify these examples to provide added
functionality or construct procedures to meet your specific needs. If you have limited
programming experience, you may want to contact a Microsoft Certified Solution Provider
or the Microsoft fee-based consulting line at (800) 936-5200. For more information about
Microsoft Certified Solution Providers, please see the following page on the World Wide Web:
http://www.microsoft.com/mcsp/
For more information about the support options available from Microsoft, please see the
following page on the World Wide Web:
http://www.microsoft.com/support/supportnet/overview/overview.asp
MORE INFORMATION
In the following example, you create a form with a graph, four text boxes,
and a command button. You type the values for Minimum Scale, Maximum Scale,
Minor Unit, and Major Unit in the text boxes, and then click the button to
see the changes in the graph.
- Open the sample database Northwind.mdb.
- Create a new form as follows:
- Use the Chart Wizard to create a new form based on the Orders table.
- In the "Which fields contain the data you want for the chart?"
dialog box, add OrderID and EmployeeID to the Fields For Chart box,
and then click Next.
- In the "What type of chart would you like" dialog box, click Column
Chart, and then click Next.
- In the "How do you want to lay out the data in your chart?" dialog
box, drag OrderID to Data (at the upper-left of the graph). Drag
EmployeeID to Axis (at the bottom of the graph). Leave Series blank,
and then click Next.
- In the "What title would you like for your chart" dialog box, type
Orders by Employee, click "Modify the design of the form or the
chart," and then click Finish.
- When the form opens in Design view, set the Name property of the Graph
object to GraphOrders.
- Add the following controls to the detail section of the form:
Text Box:
Name: MinScale
Text Box:
Name: MaxScale
Text Box:
Name: MinorUnit
Text Box:
Name: MajorUnit
Command Button:
Name: ChangeGraph
Caption: Change Graph
OnClick: [Event Procedure]
- Click the Build button next to the OnClick property of the command
button and type the following code:
Private Sub ChangeGraph_Click()
Me![GraphOrders].Axes(2).minimumscale= Me![MinScale]
Me![GraphOrders].Axes(2).maximumscale= Me![MaxScale]
Me![GraphOrders].Axes(2).minorunit= Me![MinorUnit]
Me![GraphOrders].Axes(2).majorunit= Me![MajorUnit]
End Sub
- Save the form as frmOLEGraph and switch it to Form view.
- Note the appearance of the graph. Type 1 in the MinScale box, 100 in
the MaxScale box, 5 in the MinorUnit box, and 20.5 in the MajorUnit box.
- Click the Change Graph button. Note that the Y-axis ranges from 1 to
100 in increments of 20.5.
REFERENCES
For more information about changing Graph objects, click Microsoft Access Help on the
Help menu, type graph in the Office Assistant or
the Answer Wizard, and then click Search to view the topics
returned.
Additional query words:
format
Keywords : kbdta AccCon IntpGrph KbVBA
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbhowto