Microsoft KB Archive/299825

= The Refresh command in PivotTable or PivotChart view does not display new and deleted records in Office Access 2003 and in Access 2002 =

Article ID: 299825

Article Last Modified on 3/22/2006

-

APPLIES TO


 * Microsoft Office Access 2003
 * Microsoft Access 2002 Standard Edition

-



This article was previously published under Q299825



Moderate: Requires basic macro, coding, and interoperability skills.

This article applies only to a Microsoft Access database (.mdb).



SYMPTOMS
The Refresh command in PivotTable view or in PivotChart view does not display new records or remove records that have been deleted from a table.



CAUSE
The Refresh command only displays changes that have been made to existing records. It does not requery the object to remove deleted records or to display newly added records.



RESOLUTION
You must requery the object that you are viewing in PivotTable view or in PivotChart view. You can do this by switching the object into Form or Datasheet view, pressing SHIFT+F9, and then switching back to the PivotTable view or PivotChart view. You can also programmatically requery the object by calling the Requery method.

You can also customize the PivotTable and PivotChart toolbars to call a user-defined function that requeries the active object. The following example demonstrates how to create the custom function, and how to call it from the PivotTable and PivotChart 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.  Start Microsoft Access, and then open your database. On the Insert menu, click Module to open the Visual Basic Editor and to insert a new module.  Type the following function into the module: Function RequeryActiveObject On Error GoTo RequeryActiveObject_Err Screen.ActiveDatasheet.Requery

RequeryActiveObject_Exit: Exit Function

RequeryActiveObject_Err: MsgBox Err.Description, vbExclamation, Err.Number Resume RequeryActiveObject_Exit End Function  On the File menu, click Save . On the File menu, click Close and Return to Microsoft Access. On the Tools menu, click Customize.</li> On the Toolbars tab, click to select the PivotTable check box to display the PivotTable toolbar.</li> Click the Commands tab.</li> In the Categories list, click File.</li> In the Commands list, drag Custom to the PivotTable toolbar.</li> On the PivotTable toolbar, right click the Custom control that you just added, and then click Properties on the shortcut menu.</li>  Set the properties of the Custom control as follows: <pre class="fixed_text">  Caption: Requery OnAction: =RequeryActiveObject </li> Click Close to close the property sheet.</li> On the Toolbars tab, click to clear the PivotTable check box to hide the PivotTable toolbar.</li> Click to select the PivotChart check box to display the PivotChart toolbar.</li> Repeat steps 8 through 13 to create a Requery control on the PivotChart toolbar.</li> On the Toolbars tab, click to clear the PivotChart check box to hide the PivotChart toolbar.</li> Click Close to close the Customize dialog box.</li></ol>

Now when you open any object in PivotTable view or in PivotChart view, the Requery control requeries the object's underlying data source. This causes the PivotTable view or the PivotChart view to display newly added records and to remove deleted records.

<div class="status_section">

STATUS
This behavior is by design.

<div class="moreinformation_section">

Steps to reproduce the behavior

 * 1) 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) Close the Main Switchboard form if it appears.
 * 3) On the View menu, point to Database Objects, and then click Queries.
 * 4) Click New.
 * 5) In the New Query dialog box, click Design View, and then click OK.
 * 6) In the Show Table dialog box, click the Customers table, click Add, and then click Close.
 * 7) Click the asterisk (*) at the top of the Customers field list to add Customers.* to the Field row of the query design grid.
 * 8) Click Customers.* in the Field row of the query design grid.
 * 9) On the View menu, click PivotTable View.
 * 10) In the PivotTable field list, drag the CustomerID and CompanyName fields to the Drop Totals or Detail Fields Here area. Note that the PivotTable list displays all records returned by the query.
 * 11) Press F11 to view the Database window.
 * 12) On the View menu, point to Database Objects, and then click Tables.
 * 13) Click the Customers table, and then click Open.
 * 14) Modify the CompanyName column of the first record.
 * 15) On the Insert menu, click New Record.
 * 16) Enter AAAAA in the CustomerID column and My New Company in the CompanyName column.
 * 17) Close the table.
 * 18) Switch to the query window that contains the PivotTable list.
 * 19) On the PivotTable menu, click Refresh.

Note that the changes that you made to the existing records are displayed; however, the new record that you added does not appear.

Additional query words: prb

Keywords: kbtshoot kbprb kbexpertiseadvanced KB299825

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.