Try
FOR i=_Screen.FormCount TO 1 STEP 1
IF _Screen.ActiveForm.Name <> "Main"
_Screen.ActiveForm.Release()
ENDIF
ENDFOR
>I am a software programmer in a company making accounting and inventory softwares.
>I have to make a logout option in my software, when ever the user click on logout in the menu, all the form should close and the user login form should re-run.
>
>I have partly solved this problem, but i am sort of stuck in the middle.
>In my software there is one main form, which has the property of Alwaysonbottom as .T.
>which has the name= "Main"
>
>so i have written one simple routine to close the remainning forms
>
>do while .t.
> xFrmName = _screen.activeform
> if xFrmName = "Main"
> exit
> endif
> xFrmName.release
>enddo
>
>the above code is running absolutely fine, but it crashes in one condition,that is if any of the forms which are open have the focus on the grid, then it does not releases the form, as a result it goes in the indefinite loop.
>i tried using release form, clear windows etc. but it did not work either
>
--sb--