
Addressing non-active form from .prg file
Quote:
> Try
> tinvoice.pageframe1.page1.object etc.
>>I have a FRMRECORD with a Pageframe with 3 pages
>>from a .prg file I can address any object with the following
>>_screen.activeform.pageframe1.page1.object etc
>>the FRMRECORD has a "Name" of TINVOICE
>>I need to address the form when its not active
>>but the following gives me an error saying that member
>>TINVOICE is not found
>>_screen.tinvoice.pageframe1.page1.object etc.
>>I know there must be some way around this
Joe --
A form can be addressed in several ways:
-Via a variable reference to the form object, if one exists, e.g.
m.oForm.show()
-Via the name property, if the form is a member of a formset and there's
a variable reference to the formset, e.g. m.oFormset.form1.show()
-If the form is the active form, via _SCREEN.activeForm
-Via the _SCREEN.forms array. When all else fails, this can access all
active or inactive forms.
If there are any other ways, I know the good members of this NG will let
us know about them posthaste.
Note that the name property of an object (including form objects) is
useless unless the object is contained by a parent object (in the case
of a form, a formset). There's a lot of confusion about this, I think
because _SCREEN sort of acts like a parent container and sort of
doesn't. Specifically, it has collection properties (.forms, .formCount)
like those used by containers to access their member objects, but it
doesn't behave like a container in any other way (e.g. setAll() doesn't
work).
Joe, in your case you probably need to do something like this:
*************************************
LOCAL i
FOR i = 1 TO _SCREEN.formCount
IF UPPER(_SCREEN.forms[i].name)=="TINVOICE"
invForm = _SCREEN.forms[i]
EXIT
ENDIF
ENDFOR
invForm.pageframe1.page1.object.aMethod()
**************************************
I hope this helps,
- Neil