Charts - Axis Scaling

N

ngincolorado

Charts look like they automatically scale the data with a base of zero and
increments that correspond with the top end data retrieved. I'm trying to
make my chart have more of a dramatic visual impact, resetting the base to a
number near the low end data retrieved while maintaining the top end data
retrieved limit. How do I automate this so I don't have to go in and
manually rescale it each time based on the data present?
 
R

Rob Parker

You can set the minimum value for the y-axis (vertical) by using code such
as this in the Current event of a form, or the Format event of the section
of a report which contains the chart:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
'Adjust scale of y-axis to provide sensible window
Dim lngYMin As Long
lngYMin = AnExpressionToCalculateDesiredMinimum Value
Me.Controls("NameOfChartControl").Object.Axes(2).MinimumScale = lngYMin
End Sub

The code above is taken from an old application of mine. I suspect that
using Axes(1) will set the minimum for the x-axis, but I haven't checked
that. You could also use MaximumScale to set the maximum value, if you so
desire.

HTH,

Rob
 
S

ScottyMcGill

How do I know what my "NameOfChartControl" is? Would it be the Form name as I
am using a PivotChart View of a Form?
 
R

Rob Parker

I've got no idea of how to access the chart items in a PivotChart view of a
form via VBA, or even if it's possible.

I've just done some playing with such a view, and I can't find any way of
doing it. And the object browser is not helpful. I can tell you that it is
NOT the name of the form. A Debug.Print of all the controls on the form,
when the form opens in PivotChart view, lists only the fields and their
labels which have been dragged into the PivotChart view; there is no control
shown for the ChartSpace. Maybe someone else can help here - if anyone is
still following this (rather old) thread.

If you don't get any other response here within a day or so, I suggest you
post a new question, including PivotChart View in the subject line.

Sorry I couldn't be of help here,

Rob
 
R

Rob Parker

And I now see that you have already posted your question to the
microsoft.public.access.formscoding group. Hope you get a response there.

Rob
 
Top