Make Long Reports More Readable

by Dr. Peter Wayne & Selwyn Rabins

Long reports can be hard to follow. Here are some ways to make them more readable.

As good as Alpha Five's report editor is, there are times when the standard report is just too hard to read. As an example, look at this report, the output of a simple "Customer List" from the sample Invoice.adb that comes with Alpha Five:

plain customer list

Figure 1. A plain Customer List.

See how much more readable this list is if we insert a blank line after every 5 customers:

customer list with breaks

Figure 2. The same list, now broken every 5 records.

Adding a blank line is simple enough. We just have to insert a group around the report detail, in report design mode:

insert group break

Figure 3. Insert a group break in the plain customer list.

Then in Group Properties, unselect the Group Header but leave Group Footer checked:

Group Footer selected

Figure 4. Select "Has group footer" and uncheck "Has group header."

Adjust the size of the group footer to be the same height as the detail section. Then select Report, Group Properties to establish the grouping expression:

Group Properties

Figure 5. Select Report, Group Properties.

There is only 1 group, so click on OK:

List of Groups

Figure 6. Alpha Five will show you all the groups defined - in this case, only one!

In Group Properties, enter int(mrecno()/5-.01) as the expression for the group's break:

Expression for group break

Figure 7. Expression for the group break.

If you run this report, you will see a report that looks like the one in Figure 2.

A word of explanation

Let's examine the expression, int(mrecno()/5-.01), in some detail. First, recall that the int() function returns the whole number or integer part of a number. So we have:

? int(1/5-.01)
= 0.000000
? int(2/5-.01)
= 0.000000
? int(3/5-.01)
= 0.000000
? int(4/5-.01)
= 0.000000
? int(5/5-.01)
= 0.000000
? int(6/5-.01)
= 1.000000
? int(7/5-.01)
= 1.000000

We can see that the function we used will return 0 for the first 5 numbers, then 1 for the next 5, 2 for the 3rd 5, etc.


But why did we use mrecno()? The mrecno() function returns the record number that the Alpha Five report generator creates as it generates the report. If we used the plain recno() function, our Customer List with Breaks would produce an irregularly spaced report if we applied a query to customer.dbf before running the report. That's because the query would change the order of the recno()'s for each record in the detail section. But the mrecno() function follows the report's detail section and is always accurate.

Now to get really fancy...

We can get much fancier. We can add "greenbar" shading to our reports, so that groups of records appear with alternating background colors. Here is an example:

greenbar shading

Figure 8. Here every other group of 5 records is shaded.

I owe this example to Selwyn Rabins, president of Alpha Software. The shading effect is achieved by having a conditional object in the detail section. The different shading is done is 1 of 2 ways:

  1. Either the fields themselves are conditionally colored, or
  2. A frame object is conditionally placed behind the fields that are displayed, and the background of the frame object contains the desired shading.

Both ways will work. To make the conditional object alternate between shaded and unshaded, Selwyn created a calculated field which he called grouping. Note that this name bears no relationship to a report group as shown in the first example! Selwyn calculated his field as follows:

mod(int((mrecno()-.001)/5),2)

This calculation alternates between 0 and 1. Selwyn then used the value of this field to determine which conditional object to show in his report. Rather than take you through each step of those reports, Selwyn has commented them and packaged his examples together so you can download them to study on your own!

8/22/99

Don't forget, we need your feedback to make this site better!

Return to home