jdhouse6795
02-24-2016, 07:50 AM
I am trying to find information on VBA keywords relating to chart formatting or creating in Access or MS Graph. The information I find is for Excel or the info I do find (like SeriesCollection) does not work the way I understand it. I am trying to color the slices of a pie chart created in Access based on the values that produced the chart. All available data points are not in every chart (some are zero and excluded from chart). If I could find some sites that talk about keywords and how they are used would be helpful.
jdhouse6795
02-29-2016, 10:01 PM
I have solved this myself. In case others are looking for a good answer, here it is:
On the Report format tab, make it Print Preview only, then on the Details On Format event, this is the code that works for me:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim qdf As DAO.QueryDef
Dim PieChart As Object
Dim pt As Object
Set PieChart = Me!Graph2.Object
Set db = CurrentDb
Set qdf = db.QueryDefs("LastMonthSalesbyCategoryHue")
Set rs = qdf.OpenRecordset(dbOpenSnapshot)
For Each pt In PieChart.SeriesCollection(1).Points
pt.Interior.Color = Eval("RGB(" & Val(Left(rs![CellHue], InStr(1, rs![CellHue], ",") - 1)) & ", " & _
Val(Mid(rs![CellHue], InStr(1, rs![CellHue], ",") + 1, InStr(InStr(1, rs![CellHue], ",") + 1, rs![CellHue], ",") - InStr(1, rs![CellHue], ",") - 1)) & ", " & _
Val(Mid(rs![CellHue], InStr(InStr(1, rs![CellHue], ",") + 1, rs![CellHue], ",") + 1, Len(rs![CellHue]) - InStr(InStr(1, rs![CellHue], ",") + 1, rs![CellHue], ","))) _
& ")")
rs.MoveNext
Next pt
rs.Close
Set rs = Nothing
Set db = Nothing
Set qdf = Nothing
Set PieChart = Nothing
End Sub
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.