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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem With Forms

Status
Not open for further replies.

Coolprogram

Programmer
Nov 9, 2011
15
LT
Well for example i have form1 form2 form3 .

form1 is my main form .

form2 is a data form

form3 is a search form which is called from form2 and stores results to form 2 .

When i call form2 from form1 and then call form3 from form2 it does not store results to form2 . I get error object form2 is not found

However if I call form2 without going trough main form1 , form3 stores results to form2 as it should be .

How can I fix it?

Best regards
 
There are many ways that you can do this, unless you don't post your code in detail it's totally unclear what goes wrong.

One thing in advance: Adressing forms by their names is a bad habit, you better have an object reference.

THISFORM is such a reference, but only valid in the context of a form, adressing, well this form, not that form.

But form2 can pass THISFORM to form3, you need an lparamters line in form3 init then and can store the parameter coming in as a property of form3, eg Init code would be:

Code:
* form3.init:
LPARAMETERS toForm2
Thisform.Addproperty("oForm2",toForm2)

And later you can adress form2 as thisform.oForm2, eg try Thisform.oForm2.Caption = "Caption Set from Form3" in a form3 method, eg right in the next line of form3 init.

This way of saving references has a few strings attached, eg if form2 finishes before form3 the oForm2 parameter either would hinder form2 to finish or point to an invalid memory address. But you don't have to be afraid of that, once you care for the right order of closing forms. Eg if form3 is modal you can't close form2 before form3 anyway.

Hope it helps.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top