Edit

ExpandDetail (expressionText [, searchExpression] [, rangeStart][, rangeEnd])

Result Type: List

Definition: Only available in Forms.

Returns a list of results obtained from evaluating expressionText in the context of each of the records in the list subfile for the form. The result of this function is a list of values and cannot be used in another calculation or printed on the form. You must pass the result of the function to another function that accepts a variable number of parameters, such as Count() or Sum().

If the optional searchExpression parameter is supplied, it is used as a search function to narrow the selection of list subrecords to which the expression is applied. searchExpression should be a string containing an expression that evaluates to True or False depending on the values in the list subrecord.

If the optional rangeStart and rangeEnd parameters are supplied, they are used to narrow the result to values from only those records in the range. RangeStart and rangeEnd should be numbers in the range 1-32767. If the specified range is, for example, 2 for the start and 4 for the end of the range, then the function result will have 3 values, being the results of the calculation specified by expressionText for the 2nd, 3rd and 4th records in the list. (If there are less than four records in the list, then the number of values in the result will be correspondingly less.)

Note that although the parameters will be evaluated as expressions, you must pass them to the function as text strings. The ExpandDetail function itself will evaluate the expressions.

The ExpandDetail function operates on the default selection of subrecords for the form, and is not affected by the any of the other lists on the form.

You cannot use this function in a list column calculation.

Examples:  Count(ExpandDetail("Detail.Account"))

returns the number of subrecords in the list subfile.

Sum(ExpandDetail("Detail.Net", "Detail.Account = \"1200\""))

returns the sum of the net values of all detail lines whose account code is 1200. Notice that the quotation marks in the searchExpression are escaped using the backslash.

Sum(ExpandDetail("PayAmount", "1", 1, 15))

can be used to get the sum of the pay amounts for the first 15 invoices in a cheque remittance advice. Notice that in order to specify the range parameters, a place-holding search function parameter also had to be supplied. The value 1 (= true) was used to cause all eligible records to be selected by the search function.

See Also:

ExpandList: Expand form list values to a parameter list

SubTotal: Subtotal a form list column