Skip to Content
0
Former Member
Jul 21, 2017 at 07:25 PM

Using running total in subreport

77 Views

I have 2 files: FileA (parent) and FileB (contains multiple children for each record in FileA.)

FileA

Acct PickChild

100 3

200 1

FileB

Acct ChildNum Name

100 1 Al

100 2 Barry

100 3 Charles

200 1 Amanda

200 2 Bert

200 3 Celia

I want the report to show:

100 Charles

200 Amanda

My main report has the parent id, and the subreport shows all the children records of that parent id. When showing the records in the subreport, I want the counter to show each child record with a number 1,2,3.. (I'm simplifying in describing what I want to do - I know I could put relate data from FileA and FileB in the main report). The main report will pass parameter PickChild to tell the subreport which child should be printed.

In the subreport where I created a running total of the number of records in the subreport. I created a running total field (rt_knt), as well as 2 formulas:

init: (put in report header)

whileprintingrecords;

numbervar kntrec:=0;

knt: (put in detail)

whileprintingrecords;

numbervar kntrec:=kntrec+1;

When I'm in subreport record selection, I don't have access to either of these fields - I don't see it in the report fields. While in subreport group selection, I do see formula knt, but when I do the group selection as {?Pm-PickChild}={@knt}, I get an error that this formula can't be used because it must be evaluated later.

How can I do this?

Thanks.