Microsoft KB Archive/304583

= ACC2002: How to Graphically Display Percent of Total on a Report =

Article ID: 304583

Article Last Modified on 9/26/2003

-

APPLIES TO


 * Microsoft Access 2002 Standard Edition

-



This article was previously published under Q304583



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

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



SUMMARY
This article shows you how to use two rectangle controls to graphically display a progress-bar-style percent of total in a Microsoft Access report. This example uses a table with student grades and resizes a red rectangle during the Format event of the detail section of the report to graphically indicate the grade that the students achieved.



Create a New Database and a Table Named tblGrades
 Start Microsoft Access 2002. Create a new database named Progressbar.  Create a new table named tblGrades with the following fields and properties:   Table Name: tblGrades Field Name: id  Data Type: AutoNumber Indexed: Yes (No Duplicates)

Field Name: StudentName Data Type: Text Field Size: 50

Field Name: Grade Date Type: Number Field Size: Byte Validation Rule: Between 0 and 100  Open the tblGrades table in Datasheet view. Enter the following records into the tblGrades table:

 Close the table.</li></ol>

Create a Report That Will Graphically Display Student Grades
<ol> Ensure that the Progressbar database is open.</li> Click the tblGrades table, and then on the Insert menu, click Report.</li> In the New Report dialog box, click AutoReport: Tabular, and then click OK.</li> After the wizard finishes creating the report, click Design View on the View menu.</li> Save the report as rptGrades.</li>  Click the Rectangle tool in the toolbox, and then draw a rectangle in the detail section of the report to the right of the Grade text box. Set the following properties for the rectangle control: <pre class="fixed_text"> Rectangle Name: GradeA Width: 2&quot; Height: 0.2083&quot; </li>  Draw a second rectangle on top of the GradeA rectangle, and set the following properties: <pre class="fixed_text"> Rectangle --  Name: GradeB Width: 0.0417&quot; Height: 0.1979&quot; Back Style: Normal Back Color: 26367 </li> Right-click the detail section of the report, and then click Properties.</li>  In the property sheet for the detail section of the report, set the OnFormat property to the following event procedure: Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer) Me!GradeB.Width = Me!GradeA.Width * (Me!Grade / 100) End Sub </li> On the File menu, click Close and Return to Microsoft Access.</li> Save and then preview the report.</li></ol>

Note that the student grades are graphically displayed on the report.

Additional query words: OfficeKBHowTo inf report percentage graphically display grade progressbar

Keywords: kbhowto KB304583

-

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

© Microsoft Corporation. All rights reserved.