Microsoft Access VBA Macro Programming

(Tina Sui) #1

Using theDimstatement, this code sets up an object for the chart and two variables. The
chart object is set to point to the chart on your form (assumed to be called Graph0).
Using a For..Next loop, all the points on the first series of the chart are iterated through. Each
point represents a segment of the pie chart, or in the case of a bar chart, each individual bar.
Using a Select Case statement based on the text of the data label for that point, the interior
color is set according to the currency indicator in the data label.
Open your form in form View mode and you will see that the colors of the pie chart
segment change accordingly. Experiment with changing the currency indicators in the
Currency tables and see what effect it has on your chart.
Notice that the currencies may change position in the pie chart, but they will always have
the color dictated by your code.


Chapter 33: Manipulate Chart Colors 323

Free download pdf