Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Save record frm 2 different tables
Message
From
04/05/2004 09:46:11
 
 
To
03/05/2004 01:26:53
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00899569
Message ID:
00900685
Views:
31
Jan

It's just been the weekend and a public May Day holiday so I've only just got to look at your request.

First, having looked at your table structures I think you should consider something different. On the Product table U have a product ID - but don't use it. Ur "Purchases" table (as in order lines) should reference the product ID - not its name. Also, you should have 1 "Purchase Order" tabe that features the purchase id an the name. So "Joe" wouldn't be on every record in ur "purchases" tabel. Hence ur "purchases - lines" table:

purchased id name product quantity price
1101 joe apple 5 20
1101 joe mango 3 10
1101 joe banana 6 15 should be...

purchased-id product-id quantity price
1101 p101 5 20
1101 p102 3 10
1101 p103 6 15

... with a Purchase table:

purchase-id name
1101 Joe

product table is OK but now, with the above, the "database" is normalised

To get the grid:

_______________________________________________________________
product id product name quantity price
p101 apple ____ ____
p102 mango ____ ____
p103 banana ____ ____
_______________________________________________________________
U'll need SQL such as:

Select  Purchase.*, Purchases.*, product.* ;
  from purchase, Purchases, Product ;
  where purchase.purchase_id = purchases.purchase_id ;
  and   purchases.product_id = product.product_id ;
  and   purchase.purchase_id = lnThisPurchNo ;
  into Cursor csrPurchaseLines NOFILTER

lnThisPurchNo is a var you'll have already set e.g. by having the user select a Purchase Order from, say, a combo.

Your grid you populate with whatever fields you want from the cursor.  As you're using free tables and not a database i suspect that you won't be able to use a view, but a view is essentially just an SQL select, like that above, but it's stored in the database and "is always there" and can be used just like a table.

U'll need to "manually" populate ur grid after the above SQL. 
IHTH

Terry
- Whoever said that women are the weaker sex never tried to wrest the bedclothes off one in the middle of the night
- Worry is the interest you pay, in advance, for a loan that you may never need to take out.
Previous
Reply
Map
View

Click here to load this message in the networking platform