FOR EACH loForm In _Screen.Forms IF loForm.Name = 'OrderEntry_Scx' loForm.Release() ENDIF NEXTBut the form to be closed is the second (last) of the forms, it closes the loop. Would this be safe enough? Or should I modify:
*!* local lnForms, llDone *!* lnForms = _SCREEN.FormCount *!* llDone = .T. *!* DO WHILE lnForms > 0 AND llDone *!* if pemstatus(_SCREEN.Forms(lnForms), 'QueryUnload', 5) && Toolbars don't have QueryUnload method *!* llDone = _SCREEN.Forms(lnForms).QueryUnload() *!* endif *!* IF llDone *!* _SCREEN.Forms(lnForms).Release *!* lnForms = _SCREEN.FormCount *!* ENDIF *!* ENDDO>>>The reason for this problem as you can not remove an object from collection using FOR EACH loop. This problem was discussed here before and I admit I made the same mistake myself (and may be twice even). You need to loop using counter and from the last record to the first.