I don't have any parent/child forms. I didn't even know you could do that. My app isn't very complicated, so just always using an index on 1 should work for me. Generally the user will close the forms before relogging on anyway. I just wanted a safety measure in there in case they don't.
Thanks,
-Michelle
>Michelle,
>
>You can't loop through the Forms[] collection in the forward direction like has been recommended by others. When Form[1] is released Form[2] moves down to Form[1], but your index goes up to 2 which will now release what was originally Form[3].
>
>There are two ways around this. Loop backward through the forms ie N TO 1 STEP -1 or just always use [1] as the index. It can get more complicated though if you have parent-child forms and closing the parent causes the child to be closed. My current CloseForms udf is:
>
>
>
>* 15-Jun-98 made into separate program
>
>procedure CloseForms
>
>for i = _screen.FormCount to 1 step -1
> * 15-May-98 added additional tests to prevent 1924 error
> if ( ( i <= _screen.FormCount ) and ;
> ( type( "_screen.Forms[i]" ) == "O" ) )
> if ( _screen.Forms[i].QueryUnload() )
> _screen.Forms[i].Release()
> else
> _screen.Forms[i].Activate()
> endif
> endif
>endfor
>
>
>>I need to close all the forms so the user can relogon to a different database. I'm thinking I need to do something with _screen and controls[], but I'm not sure what syntax I need.