Subforms in 4D 2004 work in such a way that the current record is unloaded if the subform is redrawn in any way by the OS (e.g. the subform loses focus).
There are two techniques that may be used to get the selected records regardless of whether or not the current record is loaded:
If the subform is set to selection mode multiple, you can use the command GET HIGHLIGHTED RECORDS to determine which records are selected in the subform:
https://www.4d.com/docs/CMU/CMU00902.HTM
If the subform is set to selection mode "single" then GET HIGHLIGHTED RECORDS is not supported. In this case you can retrieve the current record with the command Selected Record Number:
https://www.4d.com/docs/CMU/CMU00246.HTM
This Tech Note may be of interest as well:
https://kb.4d.com/assetid=37328