Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Releasing forms
Message
From
21/01/1997 10:55:56
Paul Wei
Fib, State of Michigan
Lansing, Michigan, United States
 
 
To
18/01/1997 13:32:11
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00017772
Message ID:
00017974
Views:
58
>I have a form, A that calls forms B and C which
>run at different times within it. I want to
>release B and C from a button on A but I'm getting
>the syntax wrong. I'm using myformB.release
>behind the button on form A and am getting
>told that 'yformB is not an object'
>
>
>Can anyone tell mw what Im doing wrong?
>
>Chris

Chris,

In order to refer to methods and properties of a form from outside of the form, you have to make sure the form is related to a object type memory variable and that the memory variable does not GO OUT OF SCOPE. The best way to make sure the memory variable never go out of scope is to declare it a PUBLIC variable first before assigning it to an object. Once that's done, you can then assign the form to the variable via the DO FORM command. Below are three examples which will all accomplish the same thing using the three variations of the DO FORM command:
Example 1

   public myformB
   do form myformB
   myformB.name = 'A New Name for Form B'
   myformB.CommandButton.click()
   .
   .
   myformB.release()
   release myformB

Example 2

   public oMyformB
   do form myformB name oMyformB
   oMyformB.name = 'A New Name for Form B'
   oMyformB.oCommandButton.click()
   .
   .
   oMyformB.release()
   release oMyformB

Example 3

   public oMyformB
   do form myformB name oMyformB linked
   oMyformB.name = 'A New Name for Form B'
   oMyformB.oCommandButton.click()
   .
   .
   oMyformB.release()

The first example let VFP, by default, make the previously declared public variable, myformB, into a object memory variable.  You, however, have to explicitly release the variable when you are done with it so it will not hang around.  

In the second example, you explicitly make the previous declared public variable, oMyformB, into a object variable by using the NAME option of the DO FORM command.  As with the first example, you have to release this variable yourself after the form is released.  

In the third example, the LINKED option links the object variable, oMyformB, with the form, myformB, so that when either one is released, the other is released also.  I think the third example is the preferred method of invoking forms.  
Paul
Previous
Reply
Map
View

Click here to load this message in the networking platform