I'm not sure this would work for very dynamic contexts (status changing frequently) and it feels like a clumsy solution to me, but you could try using a script which loops through Table A records (Parent) - interrogates the contents of the 'status' field of the last (if any) related (child) record and then changes a field (Parent::LastChildStatus) in the parent table if the requisite condition is met. You can then do a find on the value of Parent::LastChildStatus and use a summary field (count) in the parent table to give you your count.
For this you would need to define how a child record becomes the last record - (sort on timestamp field etc).
To check the value of a field of the "last" related record, use the last function. So one simple option is to define a calculation field in table A with this expression: Last ( Table B::Status ) (select "Text" as the result type.)
Perform a find on Table A specifying "on" in this calculation field and get ( FoundCount ) will then return the number of Table A records that have "On" as the last related record in Table B.
Thank you for your answer! I created the calculation field in table A with Last ( Table B::Status ). When I place this field in the layout of table A it shows "On", ok. Where do I have to put the get ( FoundCount )? When I perform a search in this field with "On", the result indicator shows the number of all records with "On".
Here's the manual method:
enter find mode.
Type "on" into this field
Perform the find
The found set shown in the status tool bar is the number of records where the last related record is "on".
But this can also be scripted and in a script, if you need to put this count into a field for a report or something, you can use get ( FoundCount) to get this count and put it into such a field.
Thank you very much! This solved my problem.