Things can get confusing if you multi-instance the same form. Here are a few things I've learned about working with _Screen.forms()
If, while traversing the collection, you close a form, this will require that you restart the process of traversing the collection. That is, changing the members of the collection while traversing the collection (such as within a FOR EACH loop) will cause some items in the collection to potentially be missed unless the loop is restarted.
If you need to keep track of a specific form (or window) -- again, particularly useful if you multi-instance forms -- it is helpful to give each form a unique name using a common root within the form's init. For example, if you have a form called CUSTOMER, then I've found it helpful to instantiate it with something like:
Thisform.Name="CUSTOMER_12345"
Downstream, if an event on some other form occurs such that you need to know if customer 12345's form already exists, you can do something like:
cCustomerWinName="CUSTOMER_" + cThisCustID
If Wexist(cCustomerWinName)
Show Window (cCustomerWinName) top
Activate Window (cCustomerWinName)
Else
Do Form FrmCustomer with cThisCustID
endif
You can search for a specific form and get it's object reference with a FOR EACH loop.
cCustomerWinName="CUSTOMER_" + cThisCustID
For each oCustFrm in _Screen.Forms
If oCustFrm.name == cCustomerWinName
return oCustFrm
....
and then you can use the form reference to access any items on/in the form (which itself is a container/collection data structure).
>Hi, all! Please answer which function can determinate does object (in my
sample form) exists or not. Thank you. Andrew