UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

> Chart Seriescollection, Office 2007    
 
   
birdy58
post Apr 19 2012, 08:50 AM
Post #1

New Member
Posts: 9
From: the Netherlands



Hi,
I'm new to this forum and I would appreciate any help with the following issue:
Via VBA I have access to the seriescollection of a pie chart on a form, but when copying the pie chart (including code) to a report I get a run time error 438 'Object does not support this property or method'

CODE START:

Sub SetColor(InspType As String)
Dim pReport As Report '<=================== OR FORM
Dim c As Control 'Object '<=================== OBJECT OR CONTROL MAKES NO DIFFERENCE (?)
Dim sSQL As String
Dim rst1 As DAO.Recordset

Dim MySeries As Series

On Error GoTo Handle_Error

Set pReport = Report_R_IRReason '<============= REFERENCE TO FORM WHEN CHART ON FORM

'Loop through all the controls in this report and pickout all the graphs
For Each c In pReport.Controls

'Graphs initially appear to be in an Object Frame
If TypeOf c Is ObjectFrame Then

'Check the Class of the object to make sure its a Chart
If Left$(c.Class, 13) = "MSGraph.Chart" Then

With c.SeriesCollection(1) '<================================ ERROR WHEN REPORT, OKAY WHEN FORM
'.Border.ColorIndex = 19 'edges of pie shows in white color
For j = 1 To .Points.Count
With .Points(j)
.ApplyDataLabels xlDataLabelsShowLabel
If .DataLabel.Caption = InspType Then
sSQL = "SELECT ChartColor FROM T_InspTypes WHERE InspType='" & InspType & "';"
Set rst1 = CurrentDb.OpenRecordset(sSQL, dbOpenSnapshot)

If rst1.RecordCount = 1 Then
MsgBox InspType & ", color:" & rst1.Fields(0)
End If

rst1.Close
Set rst1 = Nothing
End If
.ApplyDataLabels xlDataLabelsShowPercent
'.ApplyDataLabels xlDataLabelsShowLabelAndPercent
End With
Next
End With
End If
End If
Next

Exit_Process:
Exit Sub

Handle_Error:
MsgBox "R_IRReason_Sub SetColor: " & Err.number & vbCrLf & Err.Description
Resume Exit_Process

End Sub

CODE END

So the above code works with a pie chart on a form, but gives an error when the chart is on a report.

Can somebody help as this is annoying me for days now.
Thanks.

Bert
Go to the top of the page
 
+
 
Start new topic
Replies
birdy58
post Apr 19 2012, 10:08 PM
Post #2

New Member
Posts: 9
From: the Netherlands



AvgJoe,
Thanks, I'll look into that but it seems to involve a lot of re-programming.

arnelgp,
Thanks for the suggestion, but unfortunately it produces an other error (2771: The bound or unbound object frame you tried to edit does not contain an OLE object).
Most likely due to my ignorance I'm not able to solve it.
Can you give any suggestion?
Thanks.
Go to the top of the page
 
+

Posts in this topic


Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 21st May 2013 - 09:04 AM