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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

number Variable question

Status
Not open for further replies.

edwindow

Programmer
Jul 13, 2001
51
US
In the detail section of my report I have a formula where I assign two variables.

NumberVar x;
NumberVar y;
In the formula I return "y". But I am unable to sum on that field.
I noticed that happened when i made a basic formula that only had the number eight. I couldn't even sum on that formula. So my question is why can't you sum on values that have been declared NumberVar? And is there another declaration that I should be using?

Eddie
 
You need to add the statement y:= y + <<expression>> to calculate the totals at every record in the details section. Use other formulas to display the totals and reset the variables as needed - ie at change of group.

There is a very good FAQ regarding this. Software Support for Sage Mas90, Macola, Crystal Reports, Goldmine and MS Office
 
I tried a basic formula using that method such as

numbervar y:= 0;
y:= y+({@eight})

I put this in the detail section and I still was unable to do a summary on the formula.
 
Hi,

you have fallen for the same trap that I keep doing !!

numbervar y:=0;
y:= y+({@eight})

will reset the value to 0 every time

It should be just ...

numbervar y;
y:= y+({@eight})


you may also need to add as the first line of your formula...

evaluateafter({@eight});


Hth,
Geoff
 
first of all:

does {@eight} have the statement &quot;WhilePrintingRecords&quot; in it...if it does then you cannot preform summary operations on any other formula using it.

second of all:

this formula is very limiting as written....what is it's purpose anyway

numbervar y:= 0;
y:= y+({@eight})

you are reassigning &quot;y&quot; to zero every time so the value is just that of {@eight} every time.
Now if you want the sums of {@eight} and it does have
&quot;WhilePrintingRecords&quot; as I have suggested above then you use the 3 formula sum approach

//placed in a header to set y equal to zero (suppressed)
@Initialize

whileprintingrecords;
numberVar y := 0;

//in detail section (suppressed)
@calc sum

whileprintingrecords;
numberVar y ;
y := y + {@eight};
y;

//display in footer (not suppressed)
whileprintingrecords;
numberVar y ;
y ;

there you have it!

Jim


 
The reason I used the {eight} formula along with setting y=0 is to show that I could not sum a predefined number.
{eight} only had the number 8 in the formula. The formula I am actually using is to long to display.

The formula you gave me Jim I may be able to use. I am just trying to sum number values and Crystal didn't seem to allow me to do that unless the number value was in a database field.

Thank you everyone for your responses. I will try to apply them to my report.
 
Ed-

Not true. Crystal allows easy summing, and conditional summing using running total fields, of most formula fields.

Running totals prior to version 8 do require the 3 formula technique with variables. Software Support for Sage Mas90, Macola, Crystal Reports, Goldmine and MS Office
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top