Hi John,
The _screen.forms is a collection and is LIFO (last in / first out). What's happening is the foreach moves down through the collection closing forms as it goes, but each time a form is closed, all the remaining forms move up in the collection. Also, the forms collection will contain any toolbars so you need to trap for them.
This should work: (This calls the Queryunload method and only releases the form if it returns .T.
nFormIndex = 1
FOR x = 1 TO _SCREEN.FORMCOUNT
oForm = _SCREEN.FORMS[ nFormIndex ]
IF oForm.BASECLASS $ 'Toolbar'
nFormIndex = nFormIndex + 1
ELSE
IF oForm.QUERYUNLOAD()
oForm.RELEASE()
ELSE
nFormIndex = nFormIndex + 1
ENDIF
ENDIF
ENDFOR
hth
>Hi,
> I have a top level form.All of my data entry form are MDI form which will be active in Top level form. How could I close all active form in my top level? I use the following code, but it doesn't close all....
>
>
>FOR EACH loform IN _SCREEN.FORMS
> IF .not. loForm.NAME = mytoplevel.NAME
> loform.release
> ENDIF
>NEXT
>
>Anything goes wrong?
>
>Thank you
Roi
'MCP' Visual FoxPro
In Rome, there was a poem.
About a dog, who found two bone.
He lick the one, he lick the other.
He went pyscho, he drop dead!