A Demonstration

To demonstrate the technique of generating a report in code, I will use the database table DailySales, which is shown in Figure 26.2.

Figure 26.2. The DailySales table.

The goal is to create a fairly simple report that displays the database table records in a nicely formatted manner, with page numbers on each page. Listing 26.1 shows the procedure to create and display the report, and Figure 26.3 shows the first page of the finished report. The code is fully commented, so you should be able to understand its workings.

Listing 26.1. Creating a custom report from the DailySales table.
 Public Sub CreateCustomReport() Dim rpt As Report ...

Get Office® XP Development with VBA now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.