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

Changing property of form 2 from form 1 2

Status
Not open for further replies.

ganj

IS-IT--Management
Nov 3, 2001
19
AT
I have 2 forms (no formset, no parent-child forms).

In form 2, I have a button. In the button click event, I want to change a property of an object on form 1.

How do I do this? How do I reference form 1 from form 2?

 
Hi
DO FORM FORM1 NAME oForm1 LINKED
DO FORM FORM2 NAME oForm2 LINKED

Now you can reference.. in
Form2.cmdButton.Click
*********************
oForm1.Windowstate = 2
oForm1.BackColor = RGB(128,128,128)
... whatever..

Hope this helps you :) ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
See also thread184-10195 and thread184-65925 and thread184-164448 and thread184-164971 and thread184-253174 and thread184-262311

somebodys gotta write a FAQ on this...
 
wgcs

somebodys gotta write a FAQ on this...

Go for it, since you already did a few today...do it "one more time" :)
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
I'm afraid but this does not solve my problem yet.

How can I reference an object on form 1 from form 2? All I nned to to is change a property. I can't use linked forms nor public variable?

Why on earth is a form totally isolated from another form and how can I break this?

pls help!!!!!!!!!!!
 
Hi ganj,

I think you are mistaken. May be not !

LINKED does not mean here that the forms are linked. It is only linked to the name provided. When you release the named variable, the form also gets released. That is all it means. It is optional.

Since, you are providing a name to the form, you can reference it with that name. :)

:)
ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
also, all forms are available in the array/collection thingy in _SCREEN.Forms[ n ] ...

To make a general solution, you could search through all the forms by name using:

FOR EACH loFrm in _SCREEN.Forms
wait window loFrm.name
IF loFrm.name="myFormsClassName" ;
or loFrm.Caption="My Form's Caption"
loFrm.propertyname = whatever
ENDIF
ENDFOR


This'll support multiple forms, or if one form just doesn't exist!
 
ganj

Why on earth is a form totally isolated from another form and how can I break this?

Then use a public reference to the form
PUBLIC oForm1,oForm2
DO FORM FORM1 NAME oForm1 LINKED
DO FORM FORM2 NAME oForm2 LINKED

From form 2 try:

oFrom1.command1.click()

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
Ok, Here it is: faq184-2732 Let me know what you think!
 
@wgcs:

your solution using the _screen array is the solution I was looking for. I can't use DO FORM FORM1 NAME oForm1 LINKED
AND DO FORM FORM2 NAME oForm2 LINKED because my app is Codemine based, and this framework has another method of calling forms.

thanks to all who posted, most appreciate your help!
 
Dear wgcs

Iconic stuff

Well done!!! What a great FAQ

JF

Worth more than a mere star... but Tek-Tips offers no BLACK HOLE status.....
 
Thanks, FoxEgg!

Just revealing what I've learned from a variety of sources, packaged together in one place... I'm really curious if anyone has other methods: The issue of calling one forms PEMs from another form is really fundamental to a VFP application's architecture, since it not only relates to Forms, but ANY objects that you create.

These patterns aren't limited to VFP, either, so it's really an interesting thing to think about and discuss!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top