Inventory Table Item Description... 1 Deluxe bathroom 2 Standard bathroom 3 Double-sink Vanity 4 Single-sink Vanity 5 Bathroom faucet fixture 6 Toilet 7 Shower 8 Jacuzzi 9 Bath/Shower combo 10 Double-sink counter/cabinet 11 Single-sink counter/cabinet Link Table Item SubItem Qty 1 3 1 (deluxe bathroom contains 1 of item 3 -- double-sink vanity) 1 6 1 (deluxe bathroom - 1 of item 6 -- toilet) 1 7 1 (deluxe bathroom - 1 of item 7 -- shower) 1 8 1 (deluxe bathroom - 1 of item 8 -- Jacuzzi) 2 4 1 (standard bath - 1 of item 4 -- single-sink vanity) 2 6 1 (standard bath - 1 of item 6 -- toilet) 2 9 1 (standard bath - combo shower/bath) 3 10 1 (double-sink vanity - counter/cabinet) 3 5 2 (double-sink vanity - (2) faucet fixtures) 4 11 1 (single-sink vanity - counter/cabinet) 4 5 1 (single-sink vanity - (1) faucet fixture) So... 1 Deluxe Master Bathroom includes each of these items... Double-sink Vanity (Sub-assembly item #3) Toilet Shower Jacuzzi 2 Simple Master Bathroom includes each of these items... Single-sink Vanity (Sub-assembly item #4) Toilet Bath/Shower combo 3 Double-sink Vanity Double-sink counter top 2 Bathroom faucet fixture 4 Single-sink Vanity Single-sink counter top 1 Bathroom faucet fixture Based on the above... I would start that the person ordeded the deluxe bathroom. then do something like this... Customer Order -- BIG house... getting 2 master bathrooms... Item #1, Qty 2 */ First pass would get the deluxe bathroom */ with the first item as the double-bowl sink */ as a sub-item definition select; a.item, ; a.qty ; from ; CustomerOrder a,; Inventory b; where ; a.item = b.item; into; cursor PrimaryItems */ If not VFP7, lets re-use this cursor AGAIN to allow */ read-write and append to when locating subsidiary items select PrimaryItems use dbf() again alias C_AddToHere in 0 select C_AddToHere */ Use this cursor as basis to determine */ next cycle of records as to not recycle */ exact same items over and over... lcSubsetCursor = "PrimaryItems" llAnyMoreSubItems = .T. do while llAnyMoreSubItems */ Now, see if any more sub-assembly items... */ Ex: 2 master baths contains 2 double-counter/cabinets */ which will include total of 4 faucet fixtures, */ 2 toilets, 2 showers, 2 jacuzzis. select ; b.subitem as Item,; a.qty * b.qty as Qty; from; ( lcSubsetCursor ) a,; LinkTable b; where; a.item = b.item; into; cursor SubsetItems */ were there any found? llAnyMoreSubItems = _tally > 0 */ Now, append any such items found to the PrimaryItems */ cursor (after opening as read-write under vfp5/6) if llAnyMoreSubItems select C_AddToHere append from dbf( "SubsetItems" ) */ Now, make the lcSubsetCursor = this cursor */ as basis for next cycle lcSubsetCursor = "SubsetItems" endif enddo use in C_AddToHere */ Now if you scan through the result set for all items */ WITHOUT a sub-item definition, it should be ok for the */ inventory update. Based on the above sample, */ First pass should create */ Primary Items */ Item Qty */ 1 2 (two deluxe bathrooms) */ */ First pass for Subset items */ 3 2 (two double-sink vanity) */ 6 2 (two toilets) */ 7 2 (shower) */ 8 2 (jacuzzi) */ */ Second pass for subset items.. */ 10 2 (two counter/cabinet) */ 5 4 (two units each assembly 2 faucets = 4 faucet fixtures) */ */ Now, you should have all the items you need to update inventory... */ yes, some things may appear to get accounted for multiple times, but */ for manufacturing such things, inventory is actual based on the lowest */ items, but for "fitting the buyers" needs, which "options" appear the best */ 10 master baths selling 20 fixtures vs 20 regular baths selling 20 fixtures. */ overall, either way, 20 fixtures were sold. select PrimaryItems scan for empty( subitem ) update your inventory... based on item, qty endscanHTH