Believe me, this one bothered me occasionally for a couple of years... in the nineties. Once I solved it, it was "how could I not see such a simple thing", and "is there a softer wall around here, to bang my head against?".
>Ahah ! Thanks. I knew there must be a nicer way than a UDF().
>
>
>>>The grand total is my problem (well it's not - I just have to use a kludge to get it). If I simply sum the total field I will get 340 as the total - not 170 - as it will sum every detail record. Since the data is denormalised each detail record actually has the group total in it.
>>>
>>>Now do you see my question :)
>>
>>Ah, that one.
>>
>>Have two report variables, one cGroupExpr, and nTotal. CGroupExpr="" initially, nTotal=0. For each record, nTotal=ntotal+iif(cGroupExpr=YourGroupExpr, 0, AmountInTheRecord), cGroupExpr=YourGroupExpr. Just make sure the nTotal is created
before the cGroupExpr, so it will be assigned before the cGroupExpr. This way, cGroupExpr will be different from the group expression once for each group.