The following sample, user-defined function, PIE(), can be called from an
event property in the detail section of a report. The function uses the
Circle method to create a filled-in "pie slice" on the report:
- Start Microsoft Access and open any database.
- Create a new module and enter the following code:
Function PIE(Rpt as Report)
Const PI = 3.14159265359
Const CStart = -.00000001
Const CEnd = -2 * PI / 6
Rpt.FillColor = RGB(255, 0, 0)
Rpt.FillStyle = 0
Rpt.Circle (1500, 1500), 1500, RGB(0, 255, 0), Cstart, CEnd
End Function
- Create a new report named TestReport. The report can be bound or unbound.
- Set the OnPrint property of the detail section of the report to the following expression:
=PIE([Reports]![TestReport])
- Set the Height property of the detail section to 2.5 inches.
- Preview the report.