We help IT Professionals succeed at work.

MS Graph and Data Labels off/on as text

kdwood
kdwood asked
on
1,081 Views
Last Modified: 2007-12-19
Greetings to all,

I have an Access form with embedded chart objects.   In the chart properites, I have the Data Labels set to display the "Series Name."   I would like to be able to turn these labels off/on.   Using the code below (Fig-1), I am able to do so.  However, when I turn the Data Labels back on, they default to displaying the numeric value rather than the series name.   I attempted to use the sample code from MSDN shown in Fig-2.  However, this produces the following error:  "Run-Time error 438.  Object doesn't support this property or method."

Any help would be greatly appreciated.

Thank you,

Keith



Fig-1:

' Turn Label Off

    With Graph_Tue.SeriesCollection(3)
        .HasDataLabels = Not .HasDataLabels
    End With

' Turn Label On

    With Graph_Tue.SeriesCollection(2)
        .HasDataLabels = True
    End With

   
Fig-2:

    With Graph_Tue.SeriesCollection(2)
        .HasDataLabels = True
        .DataLabels.Text = "Late"
    End With
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2016

Commented:
  With Graph_Tue.SeriesCollection(2)
        .HasDataLabels = True
        .DataLabels.Text = "Late"
    End With
Change this
     .DataLabels.Text = "Late"
to this
     .DataLabels.Caption = "Late"

Author

Commented:
Thanks for the reply.  I modified my code to include your suggestion.  Unfortunately, I'm still getting the same error (Run-Time error 438.  Object doesn't support this property or method.")   When I press debug it highlights this line     .DataLabels.Caption = "Late"


New Code:

Dim objGraphTue As Object

With objGraphTue.SeriesCollection(2)
        .HasDataLabels = True
        .DataLabels.Caption = "Late"
End With
CERTIFIED EXPERT
Top Expert 2016

Commented:
You might be missing a library on your reference.

Check this links
http://www.kanorotterdam.nl/ariadne/pages/arp095.htm
CERTIFIED EXPERT
Top Expert 2016

Commented:
Also check if you have on your references
Microsoft ActiveX Data Objects 2.1 Library

From VBA window
Tools>References
look for  Microsoft ActiveX Data Objects 2.1 Library
and select.
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT
Top Expert 2016

Commented:
Good job!
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.