A Chart on a report displays the incorrect data in Access 2002 (318096)



The information in this article applies to:

  • Microsoft Access 2002, when used with:
    • the operating system: Microsoft Windows 2000
    • the operating system: Microsoft Windows XP

This article was previously published under Q318096
For a Microsoft Access 97 version of this article, see 317155.
For a Microsoft Access 2000 version of this article, see 318079.
Moderate: Requires basic macro, coding, and interoperability skills.

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

SYMPTOMS

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

This behavior occurs only on computers that are running Microsoft Windows 2000 or Microsoft 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 return the graph object while Microsoft Access is formatting the report, the graph object might become disassociated from its recordset. This will cause the graph object to display an unrelated record.

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

  1. Open the report in Design view.
  2. Click the section of the report that contains the graph object, and then click Properties on the View menu.
  3. In the Properties dialog box, click the Events tab.
  4. To the right of the On Format property box, click the Build (...) button, click the Code Builder, and then click OK.
  5. 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, you would type the following statement to requery the object:
    ' Replace objMyGraph with the name of your object.
    Me!objMyGraph.Requery 
    					

Method 2: Use a DoEvents Loop

  1. Create a new module.
  2. 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 to be performed is variable (it is dependent on such things as the complexity of the report, the complexity of the graph, or the number of records), a maximum value is not provided.
  3. Save and then close the module.
  4. Open your report in Design view.
  5. Open the Properties window for the section that contains the graph object, and then select the Events tab.
  6. For the On Format event, call the TestProc procedure that you created in step 2.

STATUS

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

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Start Microsoft Access, and then create a new database.
  2. Create the following table:
       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
    					
  3. Populate Sheet1 with the following sample data:

    IDField1Field2Field3
    1a12
    2b23
    3c34
    4d45
    5e56
    6f67
    7g78
    8h89
    9i910
    10j1011
    11k1112
    12l1213
    13m1314
    14n1415
    15o1516
    16p1617
    17q1718
    18r1819
    19s1920
    20t2021
    21u2122
    22v2223
    23w2324
    24x2425
    25y2526
    26z2627
  4. Create the following query:
       Query: qryTest
       ------------------
       Type: Select Query
    
       Field: Field1
       Field: Field2
       Field: Field3
    					
  5. In Design View, create a new report that is based on the qryTest query.
  6. Add Field2 and Field3 to the detail section of the report.
  7. On the Insert menu, click Chart, and then click anywhere in the detail section of the report. This starts the Chart Wizard. To add the data to the chart by using the Chart Wizard, follow these steps:

    1. Under View, click Queries.
    2. Click qryTest, and then click Next.
    3. 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.
    4. In page 3 of the Chart Wizard, click Column Chart, and then click Next.
    5. Select Column Chart and click Next.
    6. Add Field3 to the Data node.
    7. Remove items from the Axis and Series nodes, and then click Next.
    8. Select Field2 for the Report Fields and Chart Fields lists.

      NOTE: Click OK to the warning and set the fields as directed.
    9. Click Next, and then click Finish.
  8. Save and then close the report.
When the report is opened, it will display Field2, Field3, and the chart object. The chart should match the value of Field3. This is not true in all cases, because some charts will display the wrong record.

REFERENCES

Microsoft Access 2002 includes a new charting feature known as the PivotChart view. Microsoft PivotChart technology is more flexible than the technology in Microsoft Graph. Therefore, PivotChart views do not exhibit the same behavior that is discussed in the "Symptoms" section of this article.

For additional information about the new features in Microsoft Access 2002, click the article number below to view the article in the Microsoft Knowledge Base:

295358 ACC2002: What's New and What Are the Enhancements in Access 2002


Modification Type:MajorLast Reviewed:6/23/2005
Keywords:kbReport kbchart kbnofix KB318096