The application you created can only show the details of one employee at a time. Therefore you also created another version of the application which can show the details of more than one employee at a time:
Collections
To be able to display several instances of a form, you create a keyed collection of forms by adding this definition statement to WRKEMP:
DEFINE_COM CLASS(#PRIM_KCOL) NAME(#DFORMS) COLLECTS(#FRMDETAIL) KEYEDBY(#EMPNO)
This statement defines a collection of instances of FRMDETAIL called #DFORMS. The form instances are identified by the employee number.
You then change the code to refer to an instance of the #DFORMS collection. The syntax for referencing a form instance is:
CollectionName<key>
This is what the code for the Details menu option now looks like:
EVTROUTINE HANDLING(#MDetails.Click)
SET COM(#dforms<#empno>) formowner(#com_owner)
invoke #dforms<#empno>.showform
set com(#dforms<#empno>) employee(#empno)
invoke #dforms<#empno>.GetInfo
ENDROUTINE
Referring to All Form Instances
The event routine for the OKPressed event in FRMDETAIL had to be changed to refer to any detail form in the collection:
EVTROUTINE HANDLING(#dforms<>.OKPressed)
execute getlist
ENDROUTINE
When the OKPressed event is signalled from any detail form, the GETLIST subroutine is executed. As you can see from this code, no key value is specified in the collection when all its instances are referred to: #dforms<>.
Lastly, add an event routine for the Closing event of WRKEMP so that all instances of FRMDETAIL forms are closed when the main form is closed:
EVTROUTINE HANDLING(#COM_OWNER.Closing)
invoke #dforms<>.CloseForm
ENDROUTINE
An alternative way of achieving the same result would have been to set FRMDETAIL's FormStyle to Owned. This setting specifies that if a form is a member form of another form, it will be closed when the owner form is closed.
You may want to have a look at the Source Code for the Multi-Form Example Forms.