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?
- Add a property to your report called count as Integer.
- After youâve created the report object set the count to the number of students listed using your SQL count result.
- Add a group to your report. Make the group header as small as possible.
- Add a Report Label to the Group Footer.
- 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
Great idea! This solved my problem. Thank you so much!