Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calling an object in other form
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01046890
Message ID:
01046905
Views:
18
Rodrigo,

>
> I have 2 independent forms, the form1 opens form2. From a command
> button in the form2, i tried to refresh the grid placed in form1,
> but visual foxpro can not locate the object. I used: form1.object.refresh
> but it didn't work. I would like to know how can i specify the complete path
> of an object, to be sure that vfp will find it. I know there's a _screen variable,
> but i don't know how to use it or if this will be the solution to my problem. Thanks
> for your time. God bless.
>


You can call the form and give it a "name"
do form MyForm.scx name oSecondForm
Then You have the object reference oSecondForm that You can work with (You will need to have it in Your scope of course)

Another option would be to walk the _screen's forms-collection and do something like this:
lcCaption = "Edit Customer"

loForm    = FindForm(lcCaption)

if ! isNull(loForm)
    do something...
else
    wait window "Form "+ lcCaption +" not found"
endif

PROCEDURE FindForm(tcCaption as String) as Object
    local lnForm, loRetVal

    loRetVal = null
    if _screen.FormCount > 0
        for lnForm = 1 to _screen.FormCount
            if lower(_screen.Forms[lnForm].Caption) = lower(tcCaption)
                 loRetVal = _screen.Forms[lnForm]
                 exit

            endif

        endfor

    endif   

    return loRetVal
ENDPROC
Just an Idea how You could query the forms collection. However You should know that a form can be _screen.Forms[1] at one time and _screen.Forms[4] at another time. The order sometimes changes. So do NOT keep the index for further reference.

HTH
Regards from Berlin

Frank

Dietrich Datentechnik (Berlin)
Softwarekombinat Teltow (Teltow)

Frank.Dietrich@dd-tech.de
DFPUG # 327
Previous
Reply
Map
View

Click here to load this message in the networking platform