Microsoft KB Archive/318079

= ACC2000: A Chart on a Report Displays the Incorrect Data =

Article ID: 318079

Article Last Modified on 6/23/2005

-

APPLIES TO

 Microsoft Access 2000 Standard Edition, when used with:  Microsoft Windows 2000 Standard Edition

 Microsoft Windows XP Professional 

-



This article was previously published under Q318079



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

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

For a Microsoft Access 97 version of this article, see 317155.

For a Microsoft Access 2002 version of this article, see 318096.



SYMPTOMS
When you preview a report that contains a graph object, you may notice that the graph does not match the data that you expect to appear. The graph may also reference data from a previous record in the report.

This behavior occurs only on computers that are running Windows 2000 or Windows XP.

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.



CAUSE
This behavior is caused by a timing problem between Microsoft Access and Microsoft Graph. The data is first transferred from Microsoft Access to Microsoft Graph. Microsoft Graph is responsible for generating the appropriate graph. If Microsoft Graph does not generate and then return the graph object while Microsoft Access is formatting the report, the graph object may become disassociated from its recordset. This causes the graph object to display an unrelated record.

<div class="resolution_section">

RESOLUTION
To work around this problem, use one of the following methods:

NOTE: These methods may not work in all situations. ==== Method 1

Requery the Graph Object ====

<ol> Open the report in Design view.</li> Click the section of the report that contains the graph object, and then click Properties on the View menu.</li> In the Properties dialog box, click the Events tab.</li> To the right of the On Format property box, click Build (...), click Code Builder, and then click OK.</li>  In the On Format event for the section, call the Requery action for the graph object. For example, if your graph object is named objMyGraph, type the following statement to requery the object: ' Replace objMyGraph with the name of your object. Me!objMyGraph.Requery </li></ol>

==== Method 2

Use a DoEvents Loop ====

<ol> Create a new module.</li>  Paste or type the following function into the new module: Function TestProc Dim i As Integer For i = 1 To 5 DoEvents Next i End Function Because this behavior is related to timing, you may have to increase the number of iterations through the loop. Because the number of iterations that must be performed is variable, a maximum value is not provided. The number of iterations is dependent on such things as the complexity of the report, the complexity of the graph, or the number of records.

</li> Save and then close the module.</li> Open your report in Design view.</li> Open the Properties window for the section that contains the graph object, and then click the Events tab.</li> For the On Format event, call the TestProc procedure that you created in step 2.</li></ol>

<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 the Behavior
<ol> Start Microsoft Access, and then create a new database.</li>  Create the following table: <pre class="fixed_text">  Table: Sheet1 Field Name: ID  Data Type: AutoNumber

Field Name: Field1 Data Type: Text Field Size: 255

Field Name: Field2 Data Type: Number Field Size: Double

Field Name: Field3 Data Type: Number Field Size: Double </li> Populate Sheet1 with the following sample data:

</li>  Create the following query: <pre class="fixed_text">  Query: qryTest --  Type: Select Query

Field: Field1 Field: Field2 Field: Field3 </li> In Design view, create a new report that is based on the qryTest query.</li> <li>Add Field2 and Field3 to the &quot;Detail&quot; section of the report.</li> <li>Click Insert, click Chart, and then click anywhere in the &quot;Detail&quot; section of the report.

This starts the Chart Wizard. To add the data to the chart by using the Chart Wizard, follow these steps: <ol style="list-style-type: lower-alpha;"> <li>Under View, click Queries.</li> <li>Click qryTest, and then click Next.</li> <li>In page 2 of the Chart Wizard, move Field2 and Field3 from the Available Fields box to the Fields for Chart box, and then click Next.</li> <li>In page 3 of the Chart Wizard, click Column Chart, and then click Next.</li> <li>Add Field3 to the Data node.</li> <li>Remove items from the Axis node and the Series node, and then click Next.</li> <li>Select Field2 for the Report Fields list and the Chart Fields list.

NOTE: Click OK to the warning and set the fields as directed.</li> <li>Click Next, and then click Finish.</li> <li>Save and then close the report.

NOTE: When the report is opened, it displays Field2, Field3, and the chart object. The chart must match the value of Field3. This is not true in all cases because some charts display the wrong record.</li></ol> </li></ol>

Additional query words: pra

Keywords: kbbug kbnofix KB318079

-

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

© Microsoft Corporation. All rights reserved.