...
If we wish to filter the results of our sub report within the context of the band that we add it to , like, say for instance, and to see all transactions in a period sub, where the master record shows the total for the period, we will need to specify sub report joins.
to To do this, we will right click a report (sub-report) and select the menu option "Sub Report Joins". A dialog appears that allows us to select filters that will relate our master report values to the selected sub report. When that band is written to the report, the value for the current row will be passed to the sub report, and the sub will be filtered accordingly.
...
Copying a report that has joins will also copy the joins to the new report.
There are some new options in the report editor as well, if you select the main "AIMReport" object and view it's properties, you will see a new category titles titled "SubreportsSub-reports". This category has a few new parameters that we can set during report design to determine how this report will load or filter:
IsIndependentSubreport is a true/false field that will detremine determine what date is loaded and calculated for the sub report data set. when a data set is executed from it's master, the master wizard prameters parameters will override the sub parameters by default. If this value is set to true, this will prevent that from happening. Instead, the sub report will use it's own wizard parameters and filter string to load the report data.
...
When the sub report is run, the software will use the joins that we have established to generate a filter string. This filters the results that we will see in the sub report for the current band. When this is generated, it will use the expressions we set to to comare the values ( =, >=, <, etc. ). We can override this by typing our own into the FilterString property, and setting IsIndependentSubreport to "True".
...
Adding a Sub Report to An Existing Report
...
The sub report control can be found in the lower right of the screen, in the controls menu.
To add a sub report to any report drag this control onto the screen in the band that we would like to see it in. Keep in mind that where we drop the sub report will detremine how many times it is repeated. Dropping a report on the detail line of a period report, for example, with will print that report for each row of the period. If we use a period column in our repot report join the sub reports will filter accordingly. Dropping it on the report header or footer will print it once for the whole report, etc.
We'll go over this in a bit more detail in the examples below.
...
The sub report has a property called "Report Source URL", this is the most important field to remember. This field is represented as a string that will load with a list of all reports in the same category as this one. Selecting a report will use it's joins to filter the results on whatever band it is place placed on. If no joins can be found for the master report's type then the report will run without filters, on each band.
If the report we wish to add does not appear in the list, check that a.) It is in the same category b.) It is not a link, categoty category or parameter set and c.) it has not been deleted.
...
Report Source | This field is not used. If we were setting our data source like a traditional report writing tool, then the sub report data set would appear here. |
Can Shrink | If this is set to "true", then the sub report will attempt to shirink itself each time there is more space in the sub than there is rows. |
Clicking 'Save" or closing the form and selecting "Yes" on the save prompt will save all of our changes to the report and sub report properties.
...
This first exercise was to show us how simple it is to create and add a sub report. However, this example only worked out well for us because a.) we only ran the report for one flock, and b.) we set our report dates to one week, and the report to "Period" interval. For complex, filtered, repeated, sub reports we will have to make a few extra configurations to produce the desired results.
...
Now, when we run the same report, we can see that the sub is properly filtering by group.
Filtered Sub on a Group Band
if If we change the master report to Period Interval: Weekly, group the report by flock, then move the sub report to a group footer, we can see that the same report will show up as intended.
...
However, if we need to move the sub back to the detail line, because, say, we want to only see the records that pertain to that week. we do not get the results we would expect. we We need to expand the filters, and override them to filter by range.
...
Before we proceed, it is important to note that we added some functionality in this version. Prior to 1.45, users were not able to bind directly to tables tables in a data set with a parent/child relationship. Users would have to bind to the main table, then display the child records in a detail report. In this version, we have provded the option to bind directly to the child tables, and the report will run. This will greatly simplify report design for sets like the transaction set!
...
To make a report with a filter by range, we need only to open our sub report joins, then create joins with expressions that are within some bounds. The expressions can range be can be >, <, >=, <=.
For this transaction report, I want to create a report with weekly periods. For each period, I want to see a list of mortalities for that flock, by that period. To do this, we create a few extra filters with ranges, making sure that we filter the date field between the period start and end date.
We will add this sub report to our master, who'se whos period interval is set to weekly.
...
We may sometimes be able to rely on report joins for the two datasets, but this is rarely the case- especially for flocks. flocks Flocks can be transferred to or from many flocks, so there is no 1-1 relationship to relate to.
Some datasets, Like House, have a column called "Place_Combine_Origin_Code". This column lists all of the flocks that were tranferred in to this one. We can use it to filter our layer flocks, using the pullet flock itself.
Since we can't use joins, we will need to manually create a parameter ourselves, on the sub report (pictured). We will then have to set "Is Independent Sub Report" to True. We'll want to pass the pullet flock code, so create a parameter and set it to type "string"Note: If we wish to create a complex join on a datset and the fields are not there, let's create a feature ticket to add that functionality!
Because we can't add records to the Sub Report Join we'll need to write the filter string ourselves.
In the Filter String property of the sub report, we will enter a "Contains" command, comparing what's in the list of Place_Combine_Origin_Code with what we will pass into the parameter we have created above.
Here are some links relating to filter string.
The next step is passing a value into the prameter of the sub report. From the master. , where we dropped the sub report object, We will add a before print event.
...