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!

Variables not resetting

Status
Not open for further replies.

Stoffel24

Technical User
Apr 4, 2002
121
ZA
Take the following situation.

Group Header 1
Group Header 2
Details
Group Footer 2
Group Header 2
details
Group Footer 2

etc
Group footer 1

Lets say I need to keep a count of the cost of an analysis which appears in the details area. I can then use a global variable to keep track of this and report the total cost for all in group footer 1. I thought I could then refer to the same variable and reset it to 0 in every group header 1. However, when I do this, it seems to have no affect on the variable and it just keeps getting bigger and bigger. Is it something to do with when the groups are evaluated (ie all group 1 headers and footers are put in place first and then all the information for group 2 is put in place). I have tried putting in an Evaluateafter(VariableResetter) but this has not helped. What am I doing wrong. I have double checked the names of the variables to ensure there was no typo or whatever.

With thanks
Scott
 
Please post all of your formulas regarding this variable, and what section they are placed in. Software Training and Support for Macola, Crystal Reports and Goldmine
251-621-8972
dgilsdorf@mchsi.com
 
Yeah, lets see the formula. It sounds like you neglected to use the

WhilePrintingRecords;
option.

eg. (@ResetMyCounter) <- placed in ReportHeader1

WhilePrintingRecords;
numberVar MyCounter := 0

regards
 
Sorry I didn't post my formulas cause they get somewhat involved but here they are:

Group 1 = Sample.sample_type
Group 2 = Test.analysis


Formula 1 (Group footer2)=
global numbervar Cnt;

if ({SAMPLE.SAMPLE_TYPE} = Previous({SAMPLE.SAMPLE_TYPE})) then
(Global numbervar Cnt := Global numbervar Cnt + {@CountSelectedCosts};)
else if ({SAMPLE.SAMPLE_TYPE} <> Previous({SAMPLE.SAMPLE_TYPE})) then
(Global numbervar Cnt := 0;)
global numbervar Cnt

I added the else if part to try to reset the variable Cnt to zero.

@ResetCnt (Group Header 1)=
(global numbervar Cnt := 0);

THen in the Group footer 1 section, I have a formula that refers to the Cnt variable:

FinalCnt (Group Footer1) =
Global NumberVar Cnt;
 
Insert WhilePrintingRecords at the beginning of each formula which calls the variable Cnt.

If you're still left without a reset, move {@ResetCnt} so that it's the very last field to be read in GroupFooter1 and then check your output.

Naith
 
A couple of things:

>>>Group 1 = Sample.sample_type
>>>Group 2 = Test.analysis

So Group1 is based on Sample.sample_type

Place your reset formula here

**********************************

@ResetCnt (suppressed in Group 1)

//'WhilePrintingRecords' is important since it garuantees
//proper timing of the formula
WhilePrintingRecords

if not inRepeatedGroupHeader then
numbervar Cnt := 0; // this avoids accidental resets

**********************************

Now your count is placed in the Group 2 footer

*********************************
@CountingFormula
WhilePrintingRecords; //required to stay in sync
evaluateAfter(@CountSelectedCosts) //this may be required
numbervar Cnt; //define your variable once in a formula
Cnt := Cnt + {@CountSelectedCosts};

Cnt;
**********************************

NOTE: Make sure ALL of your formulas use &quot;WhilePrintingRecords&quot; unless they are summary or grouping formulas.

The if statements are not required as the grouping controles the values.

Hope this helps

**********************************




Jim Broadbent
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top