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

I'd like to read the value of a tex

Status
Not open for further replies.

ahmed1973

Programmer
Jan 29, 2013
42
DZ
I'd like to read the value of a textbox on another form.
 
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.

Bye, Olaf.
 
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)

Visual FoxPro articles, tips, training, consultancy
 
I said so, but as always you put this more verbose and easier to understand.

Bye, Olaf.
 
Olaf,

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)

Visual FoxPro articles, tips, training, consultancy
 
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.

Good Luck,
JRB-Bldr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top