access 2003 vba error 1004 unable to get tick labels property of the axis class (1 Viewer)

BT Dev

New member
Local time
Today, 05:02
Joined
Dec 3, 2013
Messages
3
I have the following code:
Dim FrmGraphObj As Object
Set FrmGraphObj = Forms![frmE Weekly Efficiency]![gph_WeeklyEfficiency].Object.Application.Chart

FrmGraphObj.Axes(xlValue).TickLabels.NumberFormat = "0%"

I continually receive a runtime error 1004 " unable to get tick labels property of the axis class"

if I remove this code, then I error on the following code:
Dim FrmGraphObj As Object
Set FrmGraphObj = Forms![frmE Weekly Efficiency]![gph_WeeklyEfficiency].Object.Application.Chart

If FrmGraphObj.SeriesCollection(2).HasDataLabels Then

also a runtime 1004: "unable to get the seriescollection property of the chart class" on the last line above


searched this forum and found:
If your chart is in a form (or report), you have to:

1) refer to the form (or report) name (Form_Charts)

2) refer to the name of the object frame holding your chart (.Graph1)

3) refer to the object within the frame (.Object)

4) refer to the application that created the object (.Application)

5) refer to the actual chart itself (.Chart)

6) refer to the axes collection and select the axis you want to reference - in this case the category, or X-axis (.Axes(xlCategory))

so....
I made the assumption, that I would just replace xlCategory with xlValue for the Y-axis. So I'm back to:
Set FrmGraphObj = Forms![frmE Weekly Efficiency]![gph_WeeklyEfficiency].Object.Application.Graph

With FrmGraphObj.Axes(xlValue)
.TickLabels.NumberFormat = "0%"
End With

Same error....
so....
Looked in the Microsoft Graph Visual Basic Reference and it indicated:
"Tick-mark label text for the value axis is calculated based on the MajorUnit, MinimumScale, and MaximumScale properties of the value axis. To change the tick-mark label text for the value axis, you must change the values of these properties."

so....
I reset my code to call these 2 functions prior to changing the number format.....
Public Sub txtMaxPercent_AfterUpdate()

Dim FrmGraphObj As Object
Set FrmGraphObj = Forms![frmE Weekly Efficiency]![gph_WeeklyEfficiency].Object.Application.Chart
FrmGraphObj.Axes(xlValue).MaximumScale = txtMaxPercent
End Sub

Public Sub txtMinPercent_AfterUpdate()

Dim FrmGraphObj As Object
Set FrmGraphObj = Forms![frmE Weekly Efficiency]![gph_WeeklyEfficiency].Object.Application.Chart
FrmGraphObj.Axes(xlValue).MinimumScale = txtMinPercent
End Sub

now I am receiving error 1004 again, this time it states "Unable to set the minimumscale property of the axis class" erroring on this line....
FrmGraphObj.Axes(xlValue).MinimumScale = txtMinPercent

debug.Print me.txtMinPercent
0.51

Please help me.....:banghead:
 

BT Dev

New member
Local time
Today, 05:02
Joined
Dec 3, 2013
Messages
3
xlValue ?

This indicates the Y-axis.....

I was able to fix my errors by initializing the graph on form_load to a query (qryChartInialize) that returned data, then use my actual query(qryEmpEfficiency) as the rowsource of the graph after the criteria the query uses was selected from the controls on my form
 

Users who are viewing this thread

Top Bottom