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!

Updating Table

Status
Not open for further replies.

tforr

Programmer
Aug 14, 2003
181
GB
Hi,

I have a table called TempInv. This table contains a number of fields. I have a new table called MyNewTable. This table has the following fields: ID and NewText.

How can I sync these tables so that they run parallel to one another i.e. record 001 in TempInv relates to records 001 in MyNewTable?

I have been told to write two methods. The first one creates the table. This is called MySetupStuff(). The other method MyUpdateStuff() should update the real table from my new table created in MySetupStuff(). What sort of code should I place in MySetupStuff?

Any suggestions would be much appreciated

Regards,

Tom
 
How can i sync these tables?

I thought I understood what you meant by "sync" until I read: "The other method MyUpdateStuff() should update the real table from my new table created in MySetupStuff()."

What do you mean by "sync"? Where to updates start? How does the user use your program? What is to be stored in the "newText" field of "MyNewTable"?


The MyUpdateStuff routine is a good idea: The one routine can be given the new values and put them into both tables at the same time... even wrapping the operation in a Transaction so that if something fails on either, neither happens.

- Bill

Get the best answers to your questions -- See FAQ481-4875.
 
Basically I have a program written in VFP. I have a tool kit that can add certain features to forms etc. I have a form and want to add an extra field to the form. I can subclass a form. With regards to tables, I have to create a new table as I don't have access to the original table. These tables need to run parallel and that is what the MyUpdateStuff() is for.

What I want to know is how can I ensure two tables work parallel with one another.

Hope I have'nt confused you Bill.

Regards,

Tom
 
What I want to know is how can I ensure two tables work parallel with one another.
There are many ways to approach this, but when you say "ensure" the one thing that comes to mind is database triggers. However, since you don't have access to change the original database or tables, we can't "ensure" the tables stay in-sync. But we can change the one form you want to so it updates the two tables in parallel.

I have a form and want to add an extra field to the form. I can subclass a form. With regards to tables, I have to create a new table as I don't have access to the original table.
Ok:
1) Create your new table manually (CREATE command in VFP)
2) Subclass the form,
3) and add the textbox for the new field. (THISFORM.txtNewField)
4) Add a form property: THISFORM.newFieldName
4b) Initialize THISFORM.newFieldName to the empty value of the data type for the new field.
4c) and set THISFORM.txtNewField.ControlSource = "THISFORM.newFieldName"
5) Override THISFORM.Init to, first, DODEFAULT(), (which probably loads the 'old' record) then to load the new table's record's value into THISFORM.newFieldName
6) Override the "save" button's Click to first save the changes in THISFORM.newFieldName, then DODEFAULT() to do whatever it used to do.

Because of the "black box" of the old form that you can't see inside of, there are many potential "holes" where the old table may get updated and your new table not get updated. However, the better the design of the old form, the easier it is to add things like this... if the original programmer isolated all "save record changes" in one method, you can override that method and piggyback on it saving your new table's stuff.

If, on the other hand, the programmer who built the old form is editing tables directly and using table buffering, you may have to take a completely different approach....


- Bill

Get the best answers to your questions -- See FAQ481-4875.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top