Link to home
Start Free TrialLog in
Avatar of kdwood
kdwood

asked on

MS Graph and Data Labels off/on as text

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
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

  With Graph_Tue.SeriesCollection(2)
        .HasDataLabels = True
        .DataLabels.Text = "Late"
    End With
Change this
     .DataLabels.Text = "Late"
to this
     .DataLabels.Caption = "Late"
Avatar of kdwood
kdwood

ASKER

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
You might be missing a library on your reference.

Check this links
http://www.kanorotterdam.nl/ariadne/pages/arp095.htm
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.
ASKER CERTIFIED SOLUTION
Avatar of kdwood
kdwood

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial