Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form not stayting in memory 1

Status
Not open for further replies.

Goofus828

Programmer
Nov 9, 2005
127
US
Here is a stumper.

I have my main form with a grid and several command buttons.

One command button called “REVIEW” calls a simple form to show the progress of a process. This form is called [blue]frmPBar[/blue]. It is called with a “DO FORM FORMS\FrmPBar”. No problems here. The command button “REVIEW" updates [blue]FrmPBar[/blue] properties with no issues. When I trace the code at this point I can see [blue]FrmPBar[/blue] as an object in the LOCALs window in the debugger.

I have another command button that calls another form in the same way “DO FORM FORMS\FRMcp”, but this one does not stay in memory! It still is on the screen but in the LOCALS window, there is no indication that it exists. When I go to update the properties on [blue]FRMcp[/blue], I get the error “Object FRMCP is not found”.

I've done a property to property comparison between [blue]FRMcp[/blue] and [blue]FrmPBar[/blue] and cannot see why one works and the other one does not.


Any Ideas?
Thanks
 
Is Frmcp modal? That is, have you set WindowType to 1. If not, that's the problem.

The reason the variable isn't listed is that it's gone out of scope.

Tamar
 
Thanks for the response Tamar, but I messed up [mad]!!

Let me see if I can explain what behavior I want:

Main form has grid and command button. (Parent form)
When command button is clicked it produces another form with a grid. (Child form)
I want Parent form and grid to have control and when i move in the main grid - the Child form's grid will update.

I've coded it all to work but like you said the second form is out of scope.
 
You need to retain an object reference to the child form in a memory variable that does not go out of scope.

One way to do that is to use a property of the main form to hold the reference to the child form.

So, in the main form, create a property named (say) oChild.

When you launch the child form, do it like this:

DO FORM FORMS\FRMcp NAME thisform.oChild

From now on, you can refer to the properties and methods of the child form by refering to thisform.oChild. As an example, to refresh the grid in the child form, you can do this:

thisform.oChild.Grid1.Refresh

That code can go anywhere in the main form, provided it is executed after you have launched the child form (obviously).

Give it a try.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Mike that worked perfectly!
Thank you so much.

I was about to change it to a form set![sadeyes]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top