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!

Variable not counting the last record

Status
Not open for further replies.

CaptainD

Programmer
Jul 13, 1999
644
US
I have a Global numbervar to count the number of times a condition is met. The numbervar is set to 0 for each separate category. In each category it misses counting the last record even though the condition is met.
I've tried to methods of "adding" for the count

(ClovisCount := ClovisCount + BaseInt;) and (ClovisCount := ClovisCount + 1;)
Any ideas?
_______________________________________________________
// Here is my code

whileprintingrecords;
Global Numbervar ClovisCount;
Global Numbervar TotalClovisCount;
Local Numbervar BaseInt;

If {incident.completed} = True And
{incident.priorityresponseflag}=True and
{incident.mutualaidcode}<>&quot;3&quot; and
{incident.mutualaidcode}<>&quot;4&quot;
Then

BaseInt := 1 else
BaseInt := 0;

ClovisCount := ClovisCount + BaseInt;
 
Where are you placing this formula, and where, if anywhere, are you resetting these variables?

Are you using BaseInt anywhere else?

Using just the bare bones of the formula, i.e.:

WhilePrintingRecords;
Numbervar ClovisCount;

If {incident.completed} = True And
{incident.priorityresponseflag}=True and
{incident.mutualaidcode}<>&quot;3&quot; and
{incident.mutualaidcode}<>&quot;4&quot;
Then

ClovisCount := ClovisCount + 1
Else ClovisCount := ClovisCount;

will it do what your original does?

Naith
 
That was the first way I tried doing it then noticed a problem so I came up with the other method. Also it is the only place I'm using BaseInt plus it's only declared as a &quot;Local&quot; variable so it should only fire for each record as the record is pulled.

In the group header I set it to zero:
_____________________________________________
//create the variable and set it to &quot;0&quot; in the group header
WhilePrintingRecords;
numbervar ResponseCount;
numbervar ClovisCount;
numbervar TotalClovisCount;
numbervar PriorityUnder5;
numbervar TotalUnder5;

// zeroed for each catagory
PriorityUnder5 := 0;
ClovisCount := 0;
ResponseCount := 0;

ToText(&quot;&quot;)
 
Insert a section below your detail section, suppress it, and place this formula into it.

I'm presuming you don't need to see this formula, only display the end result in the group footer.

Naith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top