changing Axis properties in graph

G

Guest

Hello,
I have a report with a graph which I'm changing its properties dynamically.
I want to change some of the Axes properties.
I tried using the following code: (in the on_Print event of the part in the
report the graph is placed in)

Dim objChart As Graph.Chart
Dim ax As Graph.Axis

If [Forms]![GraphicR]![someValue] = 1 Then
ax = objChart.Axes(xlVertical)
ax.Axistitle.Caption = "something"
End If

But it isn't working. when debuging I can see no value is assigned to ax
after the line:
ax = objChart.Axes(xlVertical)

the debugger writes: a = Nothing

on the other hand, the following code does work:

Dim objChart As Graph.Chart
Dim ax As Graph.Axis

If [Forms]![GraphicR]![someValue] = 1 Then
For Each ax In objChart.Axes
ax.AxisTitle.Caption = "something"
Next
End If

But this code isn't any good for me, since it changes the titles of all the
Axes. Any ideas why the first code isn't working?

thanks,
 
G

Guest

I meant of course: ax = objChart.Axes(xlValue)
instead of: ax = objChart.Axes(xlVertical)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top