Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why can't I create a total on certain columns of data

Status
Not open for further replies.

jupiter8

Programmer
Nov 22, 2002
72
GB
I can create totals using sum() on some columns of data without any problems but if the column is calculated i.e. data in column C is

(Column A / Column B)

then its just says that the sum() function can't be calculated. Also all but one formula field, (which just add twos values together) don't appear in the list of fields that can be summarised, if trying to use insert summary.

This is bound to be really simple, so please help me
 
Ok I think I just figured out why it happens, I'm using a shared variable in the formula on these columns. However I still don't know what to do about it.
 
You've correctly pointed out the culprit formula which won't go into a running total or sum function because of the fact that you very likely have a 'WhilePrintingRecords' function in there, as well you should have.

What you'll have to do is use another variable to accumulate the total. Place this either at the bottom of your subreport, or in the main report after the shared variable has been called.
Code:
WhilePrintingRecords;
NumberVar MySharedVariable;
NumberVar MyTotal := MyTotal + MySharedVariable;
When you want the total to display, call MyTotal. Remember to reset MyTotal with another formula if you want to call it at a group or page level.
Code:
WhilePrintingRecords;
NumberVar MyTotal := 0;
Naith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top