>I am creating a statistics class for on a form. I am passing the calling form as an object to the stats class. This allows easy access to the DE. I then calculate the statistics from there. It works fine when I only have one table in the DE both with and without a filter on the table. When I get to forms with 1to1 and 1 to many child tables and set a filter on one table and do statistics on fields in another table I get incorrect results. The stats end up being calculated on all of the records in the table rather than the filtered set.
You are doing the stats on the child table that has no filter. The parent table has a filter on it plus a relation into a child table. Correct? In the parent table after you set the relation to the child table, you can SET SKIP TO CHILD1, CHILD2, etc.
Now all you have to do is scan the parent table. Within the scan you can:
select parenttable
set filter to some_filter
locate
scan
id = parenttable_id
lnKount = 0
scan while id = parenttable_id
if child1.fieldX = Y
lnKount = lnKount + 1
endif
endscan
endscan
Use the SET SKIP TO from the command window, then browse the parent table to see what it looks like. Bizarre, eh? You get a ghost record in the parent table for each record in the child table.
Mark McCasland
Midlothian, TX USA