Hi friends,
i am using ms access 2003.
I have used ms graph in a form.
Now i want to set the x-axis and y-axis titles programatically.
usaully we set titles for axis by going to chart options and.............
but how can we set then programatically?
Thank you
A great reference source for dealing with the chart object programatically is as follows:
microsoft.com/default.aspx?scid=kb;EN-US;186855
In answer to your question, the following code is adapted from code written by Bob Bedell. In order for the code to work, you need to add a reference to the Microsoft Graph XX.X Object Library.:
In the illustration below, the chart control is named "TestChart". This is the OLE object embedded in the report or form that serves as a container control for the Chart object (similar to the way Forms are embedded in SubForm container controls). "Chart" is the ActiveX object hosted by the OLE container control.
The use of "Me.TestChart.Object.Application.Chart" in the example returns a reference to the ActiveX control (the reference assigned to the objChart object variable)
- Private Sub Form_Opent(Cancel As Integer)
-
-
Dim objChart As Chart
-
Set objChart = Me.TestChart.Object.Application.Chart
-
-
' Change chart title
-
objChart.ChartTitle.Text = "New Title"
-
-
' Format legend text
-
objChart.Legend.Font.ColorIndex = 5
-
objChart.Legend.Font.Bold = True
-
-
End Sub