Product
Support
Everything Else
Restricting the Number of Records on a Subform
The Problem

If there are more records in a subform than will fix on a single page, a second page is automatically created to display those records. How do I restrict a subform to show only the first n matching records and keep the view at just one page?

The Solution

Restrict the subform with an abacus query constructed along these lines:

{ key = Use key From Host_Relation }
AND
{ Count For { Item ≤ Use Item From Subform_Template } } ≤ n }

The key is that the subform records must be compared to other records within the same relation to determine whether or not they should be suppressed. To do that you must specify the subform template, not simply the relation.

This also relies on some sort of unique field (named key above) that can be used as the basis of the count. For example, if the key is a time stamp, you can get the count for all matching records whose time stamp is less than the current record's time stamp. If the count is not less than or equal to the number you want to display, the records is suppressed.

An Example

An example of this technique can be found in the collection samples on our FTP server. Look for the one that shows how the Helix Chat is built.