Format chart series from code

  • Thread starter Thread starter Rita
  • Start date Start date
R

Rita

I am trying to set the color of my dataseries 1 from VBA.
The code below is from an example in VBA-help:

me.chart.SeriesCollection(1).Interior.Color = RGB(255, 0,
0)

where "chart" is a chart-object on my form (me).

But I get the error
"Unable to set the color property of the Interior class"

What am I doing wrong?
 
Try this code:

Private Sub Form_Load()
Dim MyChart As Object
Set MyChart = Me!MyGraph.Object.Application.Chart
MyChart.SeriesCollection(1).Interior.Color = RGB(192, 192, 192)
MyChart.SeriesCollection(2).Interior.Color = RGB(40, 255, 162)
MyChart.SeriesCollection(3).Interior.Color = RGB(25, 200, 255)
MyChart.SeriesCollection(4).Interior.Color = RGB(0, 128, 128)
End Sub

Replace MyGraph with your graphs name. If this does not work try
creating a new form and graph and use the code. I have found that
Access sometimes runs into a problem when you try to change many items
on a graph. Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top