how to count record

Hi, I think it may be an old question, which I can’t locate the answer. My senario is as follows: I try to count the number of customers printed. I will use the dataitem as follows: customer ->job ->->job ledger I use printonlyifdetail = yes in customer and job dataitem. I initialise the variable “totalcustomer” in the pre-dataitem in customer. I put the code “totalcustomer := totalcustomer +1;” in different trigger. But I found that the count will include the records which do not show up (customer records do not include any job or job ledger). Please suggest the coding. I have tried to put the code in pre-section, post-section or after get record in dataitem. But the result is not correct. Thank you Richard

Hi Richard, not really an elegant solution but easy and it works… add a new job header section to your report, SectionHeight = 0, and add your code (totalcustomer := totalcustomer +1;) to the PreSectionTrigger. Saludos Nils

Nils, Thanks for your suggestion. But it doesn’t work very well. I print the total customer(totalcustomer) besides the customer every time. I found that the number is not in sequence. I mean the number will jump sometime. It may be because of no detail under those customer. Anyway, thanks Richard

This has been one of the banes of existance. Your best bet is to “cheat” by looking ahead in the OnAfterGetRecord of the Customer trigger. You’ll have to create another occurance of the Job Ledger Table filter it with a great key and do a count. If the count is greater than zero, add it to the printed customer total.