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!

I need open form with same data 1

Status
Not open for further replies.

pcwaleed

Programmer
Oct 7, 2014
29
IQ
hello
I have 1 table, contained 4 fields
code, name, age, salary
data= 1 jon 18 100
2 tom 20 150

and I have 2 forms, form1, form2
form1 contained 2 fields= code and name
form2 contained 3 fields= code, age, salary
wanted.. when I open form1 with data = 1,jon the form2 open same code to jon and other data
 
There are many ways to do that. What have you tried so far?
Also it's a bit unclear if you want to let form1 and 2 start together or start form2 from form1.

In any case what is essential is letting the forms accept a parameter
In the form designer open Init method and add this code:
Code:
LPARAMETERS tnCode

SELECT yourtable
LOCATE FOR code = tnCode

The table (yourtable.dbf) should be opened either in the dataenvironment or in the Init code right in a line before SELECT.
This should help you get goiung.

Bye, Olaf.
 
One thing is missing:
You start the form with DO FORM form1 WITH 1 and DO FORM form2 WITH 1 to let both forms display values from record code=1.

And of course you only put the controls into each form, that display the wanted fields.

Bye, Olaf.
 
Hi,
If you don't want to have both forms linked, please do have a look at the forms' DATASESSION property.
hth
MK
 
thank for all
I will try the solutions and will be back
by
 
In this case you could also use MK's indirectly advice and make use of the Datasession property.

Your form2.scx will neither need the table1 in it's data environment nor the init code. As it's dataseesion is 1, it uses the same data as the form it's started from and so all opening of tables and positioning to the right record already is done.

Bye, Olaf.
 
...datasession=1 means it uses the default datasession, tht means the current datasession. The other possible value is 2, which means it creates a new, empty datasession, where you would need to reopen the same table again and move to the same record.

Anyway, both scenarios have pros and cons:

With a private data sessions all forms operate independant on each other, have no side effect on each other besides of course updating the same data another form is bound to also changes it's display, but each form has it's own data session, his own set of workareas and record pointers. That's pro private datasession

If you remove the init code and the table, the Form2.scx will only work in case Form1.scx is opened first. If that's wanted, it's pro default data session, as it simplifies using the same data in multiple forms.
Navigoting to the code=2 record Form2.scx will then also display it, once you activate it again, without reopening the form or reinitializing it.

Bye, Olaf.
 
hello ....
can you apply your ideas on this project please
 
You can do that. Remove init code from Form2, remove table1 from form2 data environment. Simply delete these two things.

Bye, Olaf.
 
..and change the call of form2.scx in the gotoform button on form1 to:

DO FORM ..\project\form2

Without any parameter.

Bye, Olaf.
 
hello ....
can you apply your ideas on this project please
 
Sorry I wont down and upload a zip or rar to work hands on the code. That only has value to you.
Files on engineering.com will not stay forever, so this result will not contribute to a knowledgebase anyone can find in month or years from now.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top