Page 1 of 1

[Solved] How to test if a form is open?

Posted: Tue Feb 28, 2017 9:17 am
by owlbrudder
I have Googled this question and found plenty of code dating back to 2009 and thereabouts, but most of it does not work and the remainder does not answer my question.

I expected the application to be able to identify which forms are open, probably in an array, but I cannot find such an array anywhere in the object hierarchy. The Forms collection contains all the forms in the application whether they are open or not and I can't see anything the the properties of a Form that would tell me if it is open.

There must be a way, but I'm not finding it. Any help would be appreciated.

Kind regards,
Doug

Re: How to test if a form is open?

Posted: Tue Feb 28, 2017 5:09 pm
by Villeroy
A form won't be opened twice. When you double-click a form icon it will be loaded if required before its window comes up to the front. Why do you care?
In any case, the desktop object includes a collection of components. A form document is just an ordinary Writer document with an empty URL and a title like "MyDB.odb: Form1"

Re: How to test if a form is open?

Posted: Wed Mar 01, 2017 3:54 am
by owlbrudder
Villeroy wrote:Why do you care?
I am writing an application with potentially many forms and I don't want to clutter up the workspace with forms that have been in use but are no longer necessary to be open. Just being tidy, I suppose.

Anyway, you have answered my question fully as you always do - thank you.

Kind regards,
Doug

Re: How to test if a form is open?

Posted: Wed Mar 01, 2017 4:21 am
by owlbrudder
owlbrudder wrote:I don't want to clutter up the workspace with forms
Doh! (Slaps forehead). I am closing each form when the user selects another activity, so I won't have lots of forms cluttering up the workspace. (Crawls back under rock muttering).

Anyway, it is interesting to know the Desktop object is where to look.