| RTL reference|Glossary|Tips/Tricks|FREE App/VCL|Best'O'Net|Books|Link To |
| Quick Reports Tutorial | |||||||||||||||
| Page 6: Sorting, Grouping and Summarizing in Reports | |||||||||||||||
Sorting, Grouping and Summarizing in Reports Sorting on Data Grouping Data The QRGROUP component Expression - This property determines the conditions for separating one group of records from another. Usually you will simply need to enter the field in the table you are grouping on. Occasionally you will need to use more complex conditions. Since the expression dialog is the same as the QREXPR, I will not repeat how to use it here. Remember, you need a separate QRGroup header for each break you want in your report. Also each QRGroup needs to be seen from the first break inward to the last break. This is fairly intuitive, but occasionally you will make a mistake and put in the wrong field or sometimes you will need to change a grouping field in a component. Whatever the case DON'T change the position of the QRGroup component by moving it and don't leave it where it is and hope that QR will figure out that it groups these fields first and those fields second etc. What you will have to do is change the expressions of each component so that the correct order is maintained. Otherwise, the only alternative is to delete each QRGroup component and read them in the order you want.
Font - This property is useful if most of the components going into this band are going to look similar. Be sure to change this right after you place the component so that all subsequent components use this property when they are placed.
FooterBand - This is where you link the header band to the correct footer band and encapsulate your group inside. I recommend placing all your header bands first and then go back and place the footer bands by dropping a QRBand component and immediately changing the type from rbTitle to rbGroupFooter. Next name this band a unique name so that you can understand easier which footer goes with which header and why. Once you have done this, you can go back to the QRGroup header and select the right footer band to use. Also, notice that each footer does not automatically sort itself out once it is linked to a group band, so go from the inside out in your grouping so that the footers work correctly.
ForceNewColumn and ForceNewPage - Usually you would change this to true in the Footer band if you wanted a new page. You should not do this on a Group header.
The QRFooter Band Using TQRExpressions in summarizing data Master - The Master property is used to setup the input to the expression. If you are summing a field in a table then the master property must be set to this table. Setting a master to the wrong table or leaving it blank causes problems .
ResetAfterPrint - This property has caused so much difficulty because the default is false. If you want each group totaled separately you need to change the setting to true. Otherwise the total will continue to grow cumulatively.
Alignment - Change this to TaRightJustify for numeric output. It is also a good idea to change the AutoSize property to false and manually set the width of this field. You will need to ignore the text inside the field because it has no connection to what the actual output will look like.
Mask - Use this property to set the formatting of your expression. See the earlier section on how to do this.
TIP #9 |
|||||||||||||||
All graphics (if any) in this feature created by Zarko Gajic.
| More Delphi |
|
· Learn another routine every day - RTL Quick Reference. · Download free source code applications and components. · Talk about Delphi Programming, real time. · Link to the Delphi Programming site from your Web pages. · Tutorials, articles, tech. tips by date: 2001|2000|1999|1998 or by TOPIC. |
|
· NEXT ARTICLE:
Your application will be shut down!. Access violations, invalid page faults, general protection faults; the name changes, but the nature of the problem is always the same. Find the solution to your Delphi AVs. |
| Stay informed with all new and interesting things about Delphi (for free). |
|
|
| Got some code to share? Got a question? Need some help? |

