I found this in a book which builds on your code:
PivotTables and PivotCharts
In previous versions, Access forms could be confi gured to show data in PivotTable and/or PivotChart
view, which was effective for displaying multi-dimensional data or for rendering aggregated data
in a visual manner. Both relied on Microsoft Offi ce Web Components, which has already been
deprecated in previous versions of Offi ce. Excel has since refi ned and enhanced its PivotTable/
PivotChart capabilities, but those enhancements aren’t available to Access directly.
To upgrade Access solutions that make use of PivotTables or PivotCharts, you have two possible
approaches:
1. Add an ActiveX control referencing “Microsoft Offi ce XX.0 PivotTable” and/or “Microsoft
Offi ce XX.0 Chart” where XX.0 may be either 10.0 or 11.0, and update all VBA references
to PivotTable/PivotChart events and properties from the form to the added ActiveX control.
2. Instead of rendering the data in Access, automate Excel to build a PivotTable and/or
PivotChart and use Offi ce
Reference:
Hennig, T.,Clothier, B., Hepworth, G., Yudovich D., 2013 Access Programming 2-13 Wrox Wiley & Sons