Microsoft KB Archive/282392

= ACC2002: Pivot Toolbars Do Not Appear for Subform =

Article ID: 282392

Article Last Modified on 6/23/2005

-

APPLIES TO


 * Microsoft Access 2002 Standard Edition

-



This article was previously published under Q282392



Advanced: Requires expert coding, interoperability, and multiuser skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).



SYMPTOMS
In Microsoft Access, when you set the focus to a subform in PivotTable or PivotChart view, the appropriate Pivot toolbars do not appear as expected.



RESOLUTION
To work around this issue, use one of the following methods:  Right-click the subform to display the Pivot context menu for the view that is displayed in the subform.-or-

 Write custom Microsoft Visual Basic for Applications (VBA) code to handle the display of the Pivot toolbars.

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. To write custom VBA code for this purpose, follow these steps:  Open the main form in Design view. On the View menu, click Code to view the form's module.  Add the following code to the form's module: Option Compare Database Option Explicit

Private Const strToolbarPivotTable = &quot;PivotTable&quot; Private Const strToolbarPivotChart = &quot;PivotChart&quot; Private Const strToolbarPivotFormat = &quot;Formatting (PivotTable/PivotChart)&quot; Private Const strToolbarFormView = &quot;Form View&quot; Private boolSubFormFocus As Boolean Private boolFormActive As Boolean

Private Sub HandleSubFormToolbars Dim intDefaultView As Integer Dim strFormName As String If boolSubFormFocus And boolFormActive Then strFormName = &quot;Sales Analysis Subform1&quot; intDefaultView = Me.Controls(strFormName).Form.DefaultView Select Case intDefaultView Case acViewPivotTable DoCmd.ShowToolbar strToolbarPivotTable, acToolbarYes DoCmd.ShowToolbar strToolbarPivotFormat, acToolbarYes DoCmd.ShowToolbar strToolbarFormView, acToolbarNo Case acViewPivotChart DoCmd.ShowToolbar strToolbarPivotChart, acToolbarYes DoCmd.ShowToolbar strToolbarPivotFormat, acToolbarYes DoCmd.ShowToolbar strToolbarFormView, acToolbarNo Case Else DoCmd.ShowToolbar strToolbarFormView, acToolbarWhereApprop DoCmd.ShowToolbar strToolbarPivotTable, acToolbarWhereApprop DoCmd.ShowToolbar strToolbarPivotFormat, acToolbarWhereApprop DoCmd.ShowToolbar strToolbarPivotChart, acToolbarWhereApprop End Select Else DoCmd.ShowToolbar strToolbarFormView, acToolbarWhereApprop DoCmd.ShowToolbar strToolbarPivotTable, acToolbarWhereApprop DoCmd.ShowToolbar strToolbarPivotFormat, acToolbarWhereApprop DoCmd.ShowToolbar strToolbarPivotChart, acToolbarWhereApprop End If End Sub

Private Sub Form_Activate boolFormActive = True HandleSubFormToolbars End Sub

Private Sub Form_Deactivate boolFormActive = False HandleSubFormToolbars End Sub

Private Sub Sales_Analysis_Subform1_Enter boolSubFormFocus = True HandleSubFormToolbars End Sub

Private Sub Sales_Analysis_Subform1_Exit(Cancel As Integer) boolSubFormFocus = False HandleSubFormToolbars End Sub  Press ALT+F11 to return to Access.</li> On the File menu, click Save.</li> Close the form.</li> Open the Sales Analysis form in Form view.</li> Click anywhere in the subform.

Note that the PivotTable and Pivot Formatting toolbars appear on the form.</li> Click the Show PivotChart button.</li> Click anywhere in the subform.</li></ol>

Note that the PivotChart and Pivot Formatting toolbars appear on the form.</li></ul>

<div class="status_section">

STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

<div class="moreinformation_section">

Steps to Reproduce Behavior
CAUTION: If you follow the steps in this example, you modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and follow these steps on a copy of the database.


 * 1) Open the sample database Northwind.mdb.
 * 2) Open the Sales Analysis Subform1 form.

Notice that Access displays the PivotTable and PivotTable Formatting toolbars.
 * 1) Close the form.
 * 2) Open the Sales Analysis Subform2 form.

Notice that Access displays the PivotChart and PivotChart Formatting toolbars.
 * 1) Close the form.
 * 2) Open the Sales Analysis form.
 * 3) Click anywhere in the subform.

Notice that Access continues to display the default Form View toolbar, rather than the PivotTable toolbars.
 * 1) Click the Show Pivot Chart button to change the subform into PivotChart view.
 * 2) Click anywhere in the subform. Notice that Access continues to display the default Form View toolbar, rather than the PivotChart toolbars as expected.

<div class="references_section">