Solved

access 2003 vba error 1004 unable to get tick labels property of the axis class

Posted on 2013-12-03
6
788 Views
Last Modified: 2014-06-12
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"
0
Comment
Question by:baytowel
  • 4
  • 2
6 Comments
 
LVL 15

Expert Comment

by:JimFive
ID: 39693126
I believe that Axes and Series collection are under the Graph Object so:

Set FrmGraphObj = Forms![frmE Weekly Efficiency]![gph_WeeklyEfficiency].Object
0
 

Author Comment

by:baytowel
ID: 39693308
tried:
Dim FrmGraphObj As Object
Set FrmGraphObj = Forms![frmE Weekly Efficiency]![gph_WeeklyEfficiency].Object
   
    With FrmGraphObj.Axes(xlValue)
        .TickLabels.NumberFormat = "0%"
    End With

same error.....don't i need to identify as a graph object?
tried:
Set FrmGraphObj = Forms![frmE Weekly Efficiency]![gph_WeeklyEfficiency].Object.Graph
received error: runtime 438 "Object doesn't support this property or method"



found this on web (http://www.access-programmers.co.uk/forums/showthread.php?t=177778):
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

Back to the original error.....
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
0
 
LVL 15

Expert Comment

by:JimFive
ID: 39693407
This Works for me in the Current event of a form with a reference to Microsoft Graph Object Library:
Dim chrt as Graph.Chart

Set chrt = Me("Graph1").Object
chrt.Axes(xlValue).MinimumScale = .5

Open in new window


Maybe ensure that the value is being treated as a number by using CDbl(txtMinPercent)
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

Accepted Solution

by:
baytowel earned 0 total points
ID: 39695426
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
0
 

Author Closing Comment

by:baytowel
ID: 39705681
Other solutions did not apply.  Found my own solution.
0
 

Author Comment

by:baytowel
ID: 40129605
Dim FrmGraphObj As Graph.Chart
    Set FrmGraphObj = Me("gph_WeeklyEfficiency").Object

   If FrmGraphObj.SeriesCollection(1).HasDataLabels Then

returns runtime error 1004 unable to get seriescollection of the chart class
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now