Report Editor: add number of rows at the end of the list

I have created a report using the report editor with a list of students (the report is based on a RowSet from the table). At the end of the list, I want to print the number of students in the list. How can I do this? Can a local variable be printed in the footer?

isn’t the xojo example “report using groups” the thing like you want to build ?

It is not based on groups (it is only a list of students). At the end of the report I want to print the number of students in the list. It’s easy if you program the document entirely yourself, but I can’t find anything in the report editor to count the number of lines and print them at the bottom.

and what if you use “count” instead of “group by” in the sql query, and use the same technique used in the example to display the count instead of the group by sub total ?

The only summary function is SUM. I have tried to understand how the application (“report using groups”) works, but apparently you can only calculate totals based on values in fields. The sums are then displayed in a footer. I don’t see how I can enter the number of printed rows in a SUM field?

I tried to count the number of rows with a second SQL statement (SELECT COUNT(*) AS number FROM MyTable). But how can I use the result (the ‘number’ variable) in the last line of my report?

  1. Add a property to your report called count as Integer.
  2. After you’ve created the report object set the count to the number of students listed using your SQL count result.
  3. Add a group to your report. Make the group header as small as possible.
  4. Add a Report Label to the Group Footer.
  5. In the BeforePrinting event handler for the label set the text using me.text = count.ToString.

The group is used to print the count at the end of the report. See this example to see how I’ve done it.

HTH

Wayne

1 Like

Great idea! This solved my problem. Thank you so much!