Closer Inspection of Quote Report
Top  Previous  Next

It would be useful at this point to take a look at some of the code work that comes with the standard Quote report. So lets look at a few areas and explain what's going on. Go to the Calc Tab and set the Report Window to the Events View so we can walk the objects tree and look at all the code instances.

report22

Memo2OnPrint. This is the customer's address field. This is represented by a simply memo box which has no database awareness. Instead its lines are assigned in code so that we can build up a nicely laid out address with no gaps, should any address book fields in RentalDesk be empty. A memo box has a Lines property which you can set in the Design Tab itself; but for our requirements we need to do it in code as we are getting the data for the report. Take a look at its OnPrint event handler.

All this does is clear then Lines property of the memo box, then check each part of an address to confirm if it has any data in it; if there is data in the field then the Add function of the Lines property is used to add a new line to the memo box.

Groups[0].Header – BeforePrint.. Here we have some curious code:

report23
This refers to a variable component called SectionHeading (see below). This component displays the information that you type into a section heading in an equipment list. However, not all users fill this information in all the time so if it is left blank then we don't want the group header band that contains the to have a empty space above the headings fields. A report band can have a dynamic height or a static height, the former meaning that it closes up to lose any unused space. So in our formula we test to see if there will be anything printing in the SectionHeading variable and then sect the PrintHeight property of the band accordingly

SectionHeading – OnCalc. This variable component has this code attached to it:

report24
The field 'Eqlist Detail-rec Type' can have one of two value: 0 means it's a section header line on an equipment list, 1 means that its either a rental, sales or freetext line. So if the value is 0 we assign the data in the field 'Freetext-freetext' to the variable, otherwise it is blank.

Groups[0].Footer – BeforePrint.. The report summarises costs by each section on an equipment list. However, if sections are not being used and event the default equipment list section is blank, then we do not want to should this footer band as there is no point. Hence the code:

report25

Groups[1].Header – BeforePrint.. We don't want to print the header band for the MasterCategory group if the current record being traversed by the report is a section header; however, we (the RentalDesk developers) can't just set it to be visible if the report is now traversing data which is not a section header since the you may have set this section to be invisible anyway on the Design Tab.

report26

Here McatVisible is a global Boolean variable which is defined in the Module View of the Report Window and initialised in the Report's OnCreate event to store the GroupHeaderband3.visible property. Switch to Module View and select the Declarations and Events nodes to see this implemented.

Similar techniques are used for the remaining header and footer bands, as well as the Detail Band, so we'll skip these areas.

FDescriptionOnCalc. . FDescription is a variable component which has the important job of printing the descriptions of all the equipment on your list.

report27

First we check if the record being traversed contains data which tell us its NOT a section header. However, we have a further problem to tackle because if there entry is a piece of freetext then it is stored in a different table to the main RentalDesk inventory. We can test this by examining the field SubType in the table Eqlist_Detail. This can hold one of three values:

1 – Rental items  
2 – Sales Item  
3 – FreeText item  

So it the record being traversed in the data is NOT a Section Header and NOT a FreeText item then print the information from the Types-DescriptionA field, otherwise print the information from the 'Freetext-freetext' field

Summary band – BeforePrint. The Summary Band prints at the end of the report, but if this occurs at the top of page 3 then this can look a bit silly: information with sub-totals and the like look nicer at the bottom of the page. We could achieve this by putting them in the Page Footer but this would mean printing them on every page. So instead we tell the Summary Band to print at the bottom of the page:

report28
This bit of code should give a bit of insight into just how much control you can have over your report….with a little bit of work! J