I’m getting a type miss match (error 13) on the indicated line show below.
Dim subFormPTbl As Form ' the subform with pivot table
Dim PTbl As PivotTable ' refers to pivot table
Dim PTblFld As PivotField ' a column field in the pivot table
Set subFormPTbl = Me.SuformWithPivot.Form
Set PTbl = subFormPTbl.PivotTable ' < === ERROR HAPPENS HERE
For Each PTblFld In PTbl.ColumnFields
If PTblFld.Selected Then
Debug.Print "Selected column field name is " & PTblFld.Name
I have a main form with a subform. The subform refers to a form with a default view set to pivot table. All I need to do is to list the column fields that are selected by the user.