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

Count Not Including First Record

Status
Not open for further replies.

LHG33

Technical User
Jan 16, 2002
24
0
0
US
Hi! I am trying to count records but can never get my totals right! I am trying to count records except for those whose RunTable.DebCred = P, but resetting at P or a new endpoint. The #PageCount used below counts the records and evaluates RunTable.DebCred in "D" and "C" and resets at P or a new endpoint.

Here is my formula:

EvaluateAfter ({#PageCount});
NumberVar PageCount;
If {RunTable.DebCred} = "P" Then
(PageCount := PageCount)
else
if (Previous({RunTable.Endpoint})) <>{RunTable.Endpoint}) then
(PageCount:= 1)
else
PageCount:= PageCount + 1 ;
PageCount;


I have this formula in the Details section beside the records to check it and discovered that the very first record of the report does not have a number beside it. My count starts on the second record. I have changed if RunTable.DebCred = P to reset PageCount := PageCount + 1 and then it will count the first record, but it screws up the rest of my counting. What can I do to correct this?

Thanks!


 
Why are you using an evaluateafter #pagecount?

This looks close, I didn't test it:

whileprintingrecords;
NumberVar PageCount;
If {RunTable.DebCred} = &quot;P&quot; or
(Previous({RunTable.Endpoint})) <> {RunTable.Endpoint}) then
PageCount:= 0
else if
onfirstrecord then
PageCount:= 1
else if
PageCount:= PageCount + 1;
PageCount;

This assumes that you want to NOT count the P or changed endpoints as rows. then you can conitionally suppress based on Pagecount = 0 to eliminate those rows from the count.

I may misunderstand though, try posting example data and expected output.

-k
 
Hi K, and thank you very much for responding! :)

I apologize....I am trying to alter someone else's report and haven't given all the info you needed. I was testing the aforementioned count formula in the Details A section next to the records being counted to see where I was going wrong, but actually there is a Details B where the formula belongs. The formula is printing once at the bottom of most pages with the count being how many items are on that page, with the page breaking at RunTable.DebCred = P (I set that in the Format section). I am probably not explaining this very well but here's a sample page--hopefully it will help:
Page Header
Group Header (Suppressed)
Details A: DebCredRecord
DebCredRecord
DebCredRecord
(Breaks at P)

Details B: PageCount formula (at bottom of page once)
Group Footer
Page Footer


 
EvaluateAfter ({#PageCount});
NumberVar PageCount;
If {RunTable.DebCred} = &quot;P&quot; Then
(PageCount := PageCount)
else
if (Previous({RunTable.Endpoint})) <>{RunTable.Endpoint}) then
(PageCount:= 1)
else
PageCount:= PageCount + 1 ;
PageCount;

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

1. If {RunTable.DebCred} = &quot;P&quot; Then
(PageCount := PageCount)

I don't really see the point to this. You haven't changed anything.

2. else
if (Previous({RunTable.Endpoint})) <>
{RunTable.Endpoint}) then

The problem is that on the First record you are refering to a Previous ( = to NULL) value in this If-Then

I assume that if this is true then you want PageCount to be unchanged like the previous.

3. You use too many parentheses

I would suggest the following formula


EvaluateAfter ({#PageCount});
NumberVar PageCount;
If {RunTable.DebCred} = &quot;P&quot; or PreviousIsNull({RunTable.Endpoint}) Then
PageCount := PageCount // I am leaving this here even though I don't understand why it is here
else if Previous({RunTable.Endpoint}) <> {RunTable.Endpoint} then
PageCount:= 1
else
PageCount:= PageCount + 1 ;

PageCount;


Jim Broadbent
 
K,

Here is some sample data:

090123345 5235-4543 $45.50
090123350 6566-8646 $322.54
090124500 9867-8868 $78.36
090135650 7632-0989 $32.75

4 Items

The records are numbers assigned to an item, the account number for the item, and amount of item. DebCred is Debits and Credits, with P being Pocket Separators. The Items total at the bottom is the count formula and should be at the bottom of the page in Details B. The records break at DebCred = P but does not show P or count it. The records will also break on change of the only group, RunTable.Endpoint. It just counts all other items on the page and resets at P, the page break.

I hope this is more what you were looking for.

Jim,

Thank you for your suggestions! I will give them a try on Monday. To explain your confusion, I am not a programmer...I have just picked up things here and there. :p
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top