By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,325 Members | 1,886 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,325 IT Pros & Developers. It's quick & easy.

Ms graph axis title

P: 86
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
Dec 8 '07 #1
Share this Question
Share on Google+
6 Replies


puppydogbuddy
Expert 100+
P: 1,923
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)


Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Opent(Cancel As Integer)
  2.  
  3.     Dim objChart As Chart
  4.     Set objChart = Me.TestChart.Object.Application.Chart
  5.  
  6.     ' Change chart title
  7.     objChart.ChartTitle.Text = "New Title"
  8.  
  9.     ' Format legend text
  10.     objChart.Legend.Font.ColorIndex = 5
  11.     objChart.Legend.Font.Bold = True
  12.  
  13. End Sub
Dec 9 '07 #2

P: 86
Thank you friend.

But the code did'nt have any option to put title of axis.
we can put the title of the Chart.
But i want to set the titles for x and y axes.

also the link is not working. That link directly took me to home page.


What to do?

Thank you
Dec 10 '07 #3

puppydogbuddy
Expert 100+
P: 1,923
Thank you friend.

But the code did'nt have any option to put title of axis.
we can put the title of the Chart.
But i want to set the titles for x and y axes.

also the link is not working. That link directly took me to home page.


What to do?

Thank you
Sorry about that, here is the correction to the previous link plus additional link that I found in my files.

http://support.microsoft.com/kb/186855

http://www.download.com/3000-2251_4-....html?tag=dl.1

I will get back to you as soon as I can on the other info.
Dec 10 '07 #4

P: 86
i will get back to you as soon as I can on the other info.

ok thank you friend for the links and your response. If you find that please get back
Dec 10 '07 #5

P: 86
Hi friend,
welcome back.

atlast i solved the problem .
'for x axis tile
Me.YourGraphName.Object.Axes(1, 1).AxisTitle.caption = "hello"

'for y-axis title
Me.YourGraphName.Object.Axes(2, 1).AxisTitle.caption = "hello"


but before doing this make sure that you have set the x-axis and y-axis tiltes with some name by manually.
Dec 10 '07 #6

puppydogbuddy
Expert 100+
P: 1,923
Hi friend,
welcome back.

atlast i solved the problem .
'for x axis tile
Me.YourGraphName.Object.Axes(1, 1).AxisTitle.caption = "hello"

'for y-axis title
Me.YourGraphName.Object.Axes(2, 1).AxisTitle.caption = "hello"


but before doing this make sure that you have set the x-axis and y-axis tiltes with some name by manually.
Hi ravindarjobs,
I am glad you got your problem resolved. And thanks for posting back with the solution. It will help others with the same problem. Did the links I gave you help you? Let us know.
Dec 11 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.