Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't add totals to Pivottable

Status
Not open for further replies.

marle35

Programmer
Jul 17, 2007
36
I am building a pivottable programmatically, and I am able to add all the appropriate row, columns, and detail data, but I am unable to add totals. I have tried this with Access 2000 Pivottables 9.0 and Access 2003 Pivottables 10.0. Access 2000 gives an error stating something like "You cannot use that function on that field." Access 2003 doesn't tell me the error but the totals don't show up. I have tried both plFunctionSum and c.plFunctionSum. How do I get it to work?

The code:

Dim pFieldset
Dim pField
Dim pTotal

Set pFieldset = PivotTable0.ActiveView.FieldSets("SupplierName")
PivotTable0.ActiveView.ColumnAxis.InsertFieldSet pFieldset

Set pFieldset = PivotTable0.ActiveView.FieldSets("CategoryDescription")
PivotTable0.ActiveView.RowAxis.InsertFieldSet pFieldset

Set pFieldset = PivotTable0.ActiveView.FieldSets("ItemDescription")
PivotTable0.ActiveView.RowAxis.InsertFieldSet pFieldset

Set pFieldset = PivotTable0.ActiveView.FieldSets("Price")
PivotTable0.ActiveView.DataAxis.InsertFieldSet pFieldset

Set pField = PivotTable0.ActiveView.FieldSets("Price").Fields(0)

Set pTotal = PivotTable0.ActiveView.AddTotal("Total Price", pField, plFunctionSum)
PivotTable0.ActiveView.DataAxis.InsertTotal pTotal
 
I just want to add that I would like to get it to work in Access 2000.
 
Any links to sample Access databases that manipulate Pivot Tables would be helpful too. I'll take any help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top