I have been trying to add data labels to my pivot charts programmatically through VBA, but I can’t seem to figure it out. I’ve looked everywhere online, but nothing seems to work for my particular case.
Dim myForm As Form
Set myForm = Forms("My Form")
This may be fairly simple, but how do I access the ‘HasDataLabels’ property from there? I need to add it to two series.
Ethen,
Here is a little VBA that can be used to add data labels to a form being viewed as a pie chart pivot chart. Please note, this code may cause errors if the form is not viewed as a pivot chart, because ChartSpace may not be available.
You might find this link helpful as well: Programming PivotTable Reports in Microsoft Access 2002
There are many ways to format charts in Access VBA. It has turned out to be more robust for my users when I create the entire chart programmatically, this avoids problems with users accidentally “corrupting” the charts by unknowingly dragging controls, because the chart is recreated from scratch each time the form is loaded.
Using the code above requires a reference to OWC10 (Microsoft Office XP Web Components)