But in case of MDICHILD windows, the code following the ACTIVATE command is executed immediately after activating the window and we can not release the resources or close the data table after ACTIVATE command.
Therefore, we write the clean up code like release of resources and closing data tables/recordset in the VALID clause of the Window. But this is not totally safe.
There is a very small time between the data is closed in the valid clause and the window and browse are closed. If for some reason the browse needs to be refreshed in that small gap of time runtime error occurs. This issue was discussed in the forums earlier but no satisfactory solution was found.
Now the new DATA bPostEnd of TMdiChild class provides a reliable solution to this problem.
Instead of closing the data ( partcularly recordset ) in the VALID clause, we can do that in the codeblock oWnd:bPostEnd.
- Code: Select all Expand view
oWnd:bPostEnd := { || oRs:Close() }
Postend block is guaranteed to execute after the browse and window are closed. For the same reason, we better do not refer to the internal data of the browse or window.