You can use the GetSummary function to get the summary value of the records.
Actually, summary fields are not really layout dependent though it can look that way. The value returned by a reference to a summary field depends on either:
1) The table occurrence of the current layout. (Summary fields when accessed directly, return values determined by the current found set and sort order. Each table occurrence has it's own found set and sort order.) When you reference the value on a layout that is based on the table where it is defined, you get the grand total just as though you put it in the footer or a grand summary part. As sorbsbuster has already indicated, you can use get Summary to extract the sub total shown in a sub summary part--but one of the records in this group must be your current record.
2) The relationship between the current record and the related table where the summary field is defined. If the summary field is defined in a related table, the value returned will be the summary value of all related records. If you define a total amount summary field in an invoice systems line items table, referring to it from an Invoices record will produce the total of all lineItems records for that one invoice.