You can't without having a form reference to the other form.
This is not the way you should handle access. What you want is access to the value. If a value is of interest in two form, either you pass a value on to the second form via DO FORM... WITH parameter and receive the value in the second form INIT in LPARAMETER tPassedInValue or you store values into tables and read them in the other form.
Form communication by accessing other forms control values is a sign of a bad application design. The form will depend on each other this way, this is not what you should do. Forms are normally closable independant of each other and so code readiong from another form would fail if that's closed. That's just one of the problems you'll be facing. If the two forms really belong to each other and depend on each other, integrate all the controls in one form, or use a pageframe and use it's pages to have more space.
I second everything Olaf said. However, if the second form happens to be called from the first form, you can pass the value of the textbox as a parameter to the second form. Something like this:
DO FORM SecondForm WITH thisform.Text1.Value
Then, in the Init fo the second form, you would retreive the value with an LPARAMETERS statement:
LPARAMETERS lcValue
Then either use lcValue within the Init, or store it in a property of the second form so that you can use it later.
Mike
__________________________________
Mike Lewis (Edinburgh, Scotland)
I seem to be having a blind spot lateley. I read your post, and saw what you said about passing a parameter, but between reading it and writing my reply, it somehow flew out of my head. This seems to be happening more and more lately.
Mike
__________________________________
Mike Lewis (Edinburgh, Scotland)
You have already received excellent advice from Olaf and Mike above.
I will, however add one suggestion that MIGHT be applicable depending on the circumstances.
IF you were to have 2 Forms open concurrently (where the the second form is NOT called from the first form) and need to have one form 'read' data from the other, then you might consider 'pushing' the data values from Form1 upon entry into a data table which Form2 could then read periodically (maybe use a Timer object to do so).
That might not be the situation you need to support, but it is just one approach to handling it if needed.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.