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

between forms

Status
Not open for further replies.

achen

Programmer
Jul 21, 2000
11
US
I have say 2 forms: A and B.&nbsp;&nbsp;Form A is a data entry screen.&nbsp;&nbsp;From form A, I can click push button and go to form B.&nbsp;&nbsp;In form B, I have a list of information for users to select.&nbsp;&nbsp;My questions are:<br>(1) I have a DONE push button in form B.&nbsp;&nbsp;What code should I put in the click method of the DONE push button in form B, so when the user click it they can (1)go back to form A with all the information they type in previously, (2) transfer the information selected in form B to form A, and (3)let form B disappear??<br><br>Thanks.<br><br><br>
 
*switching forms... in click event<br>oFormNameA.WindowSate = 1 && minimized<br>oFormNameB.WindowSate = 0 && normal<br>oFormNameB.SomeControl.Setfocus()<br><br>***assumes neither is modal and both are in screen<br><br>You might consider using the tab control. Put both forms in one form, your users select the tab they want to be in.<br><br>To transfer info between forms... you can pass parameters to the init event, use public variables, or add properties to each form and reference them, I have even used a cursor before.&nbsp;&nbsp;<br><br>The simplest method is to use is probably public variables but it can will be a nightmare to debug later and I don't recommend it.&nbsp;&nbsp;Which to choose really depends on how the forms are used, closed and called.<br> <p> <br><a href=mailto:blindpete@mail.com>blindpete@mail.com</a><br><a href= > </a><br>
 
On second thought... Why use two forms or tab controls at all.&nbsp;&nbsp;Use a combo box to list the options for data entry. <p> <br><a href=mailto:blindpete@mail.com>blindpete@mail.com</a><br><a href= > </a><br>
 
I create objects, say for a customer, and then create properties which are form objects.&nbsp;&nbsp;This way, all properties and methods of all form objects belonging to the customer object, say, are accessible to every other object belonging to the customer object(including the customer object itself).<br><br>e.g.<br><br>this.text1.value = this.parent.formb.text1.value<br>where parent is the customer object.<br><br>customerObject_o<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;¦<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;----forma<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;¦<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;----forma properties and methods<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;¦<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;----formb<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;¦<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;---formb properties and methods<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;¦<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;¦<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;---customer object properties<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;¦<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;¦<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;---customer object methods<br><br>I find this approach makes sharing data easy throughout the application.<br><br><br>
 
What a clever approach!&nbsp;&nbsp;Do you ever have performance problems with large apps?&nbsp;&nbsp;IE windows starts augmenting ram with the hdrive?&nbsp;&nbsp;Just curious... <p> <br><a href=mailto:blindpete@mail.com>blindpete@mail.com</a><br><a href= > </a><br>
 
Simo,<br>How are you scoping the form objects to the cust object?<br>This.cForm1=?<br>This.oForm2=?<br>Thanks looks good <p>John Durbin<br><a href=mailto: john@johndurbin.com> john@johndurbin.com</a><br><a href= </a><br>ICQ #9466492<br>
ICQ VFP ActiveList #73897253
 
Performance: starting the application and closing down the application I do find is slower than normal, however, once the application has opened I find that because forms are already initialised as objects they pop up on the screen extrememly fast.<br><br>I also open all my tables at the start of the app and keep them open, thus eliminating having to wait for foxpro to open the tables everytime I want to perform an operation on them.<br><br>ok - this is how my application is layed out, people may think what a daft method but it works for me and is easy and quick to create once you have the initial templates set up.<br><br>1.  entity objects, i.e. customer, supplier, invoices, orders, etc.<br>2.  data access objects<br>             ¦<br>             -----record object<br>                ¦<br>                -----field object<br>3.  interface objects(forms saved as classes)<br><br>I create a customer object say, which can contain data access objects for as many tables as it uses.<br><br>Data access objects are passed a table name, opens the table and creates a record object, and field objects for each of the fields in the table (the record object is essentially just a skeleton to hold the fields in place).<br><br>So, if i had just one customer table(for this example), I would do the following command:<br><br>this.addObject('recordObject','customerRecordObject_o')<br><br>Once this is done, I can reference the data in the table indirectly, i.e. if i wanted to get the customer reference I would do this:<br><br>ref = this.customerRecordObject_o.custRef.value<br>(custref is a field object which is a property of the record object).<br><br>I can save and restore using the following method:<br>this.customerRecordObject_o.pop()   && gets data to mem<br>this.customerRecordObject_o.push()  && commits data to disk<br><br>one field would be:<br>this.customerRecordObject_o.custRef.pop()<br>this.customerRecordObject_o.custRef.push()<br><br>I also have record locking methods also.<br><br>In the main entity object I also have lots of search and find code to remove me from the table-level operations and thus prevent (easy to make) mistakes such as moving a record passed EOF, typing GOOT instead of GOTO, etc - I never actually issue this command anymore.<br><br>To add form classes to the entity object(in this case customer) I do something similar to this:<br><br>this.addObject('mainCust_frm','mainCustForm_o')<br><br>Therefore text boxes, etc on the form objects can be assigned to my data objects, i.e.:<br><br>thisform.custRef_txt.controlSource = ;<br>    thisform.parent.customerRecordObject_o.custref.value<br><br>I think that I will get kicked off if I take too much more space in this thread soon :)<br><br>All my entity objects are also members of the main application object(thisapp), therefore every single object can be accessed down a hierarchy making sharing data and methods easy - but it can get messy if it is not managed properly, methods should still be assigned to the correct objects, I try not to have any code apart from validation on my forms, and have all the main processing code in the entity objects, I find that this makes forms much faster and smaller.<br><br>The downside, is of course, that all my code is stored in one class library, so if this goes wrong - no, I won't think about that, that's what backups are for :)<br><br>If you are interested an want to know more about how I do things then let me know.
 
Have you read VFP 6 Enterprise by Paddock & Peterson.&nbsp;&nbsp;You may find their enterprise classes interesting.&nbsp;&nbsp;I'm just reading it now <p>John Durbin<br><a href=mailto: john@johndurbin.com> john@johndurbin.com</a><br><a href= </a><br>ICQ #9466492<br>
ICQ VFP ActiveList #73897253
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top