Update selected records in a 3rd table from a Grid, VFP 5 
Author Message
 Update selected records in a 3rd table from a Grid, VFP 5

In a form in VFP 5 I have data about orders in a grid.  Structore is

        table1  -- 1 to n --> table2 -- 1 to 1 --> table3

Table1 is header record for items ordered from a vendor
Table2 is line items ordered from vendor
Table3 is information about item ordered, in particular price for an item

If the price of an items changes (as determined by data in table2) I need to
update the price for the item in table3.  I am trying to figure out what the
best way to do this is.   An outline of what I came up with is

a. put key for table3 and new price in a cursor
b. select cursor
c. use SCAN/ENDSCAN to find matching key from cursor in table3
d. if key is found update price in table3 with equivalant value in cursor



Sat, 12 May 2001 03:00:00 GMT  
 Update selected records in a 3rd table from a Grid, VFP 5

[ Courtesy cc'ed through e-mail to the quoted author ]

Quote:
>In a form in VFP 5 I have data about orders in a grid.  Structore is

>    table1  -- 1 to n --> table2 -- 1 to 1 --> table3

>Table1 is header record for items ordered from a vendor
>Table2 is line items ordered from vendor
>Table3 is information about item ordered, in particular price for an item

>If the price of an items changes (as determined by data in table2) I need to
>update the price for the item in table3.  I am trying to figure out what the
>best way to do this is.   An outline of what I came up with is

>a. put key for table3 and new price in a cursor
>b. select cursor
>c. use SCAN/ENDSCAN to find matching key from cursor in table3
>d. if key is found update price in table3 with equivalant value in cursor

As I understand it, key in table3 is unique for the item, right?  So why not to
save new price and key to memory variables and do

REPLACE ALL table3.price WITH newprice FOR table3.key == savedkey

You will need to restore relation (if used) and/or requery after that.

[ When replying, remove *'s from address ]
Alexandre Pechtchanski, Systems Manager, RUH, NY



Sat, 12 May 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Updating A Record Within A Grid (And Trying Not To Move Off Record Till Done)

2. select the most updated record

3. Record pointer moves in grid but value doesn't update

4. afteter adding records, grid doesn't update

5. Help: Filling a One-To-Many grid with selected records

6. SQL-Select Record no of table1 (table 2 for selection)

7. selected record in a grid

8. double click in grid to select a record?

9. FPW 2.6, Selecting records based on criteria in multiple tables

10. SELECT finding other records in same table with date +- 5 days

11. Move selected record to top of grid

12. Selecting two records from the same child table?

 

 
Powered by phpBB® Forum Software