View Full Version : Update the Foreign Key


Mahoney
02-04-2009, 01:30 PM
Hello,

I am currently working on a DB, where the main table is linked to many other tables, the main table is linked to the other tables in the foreign keys.
The main table has information of a product which is required to be produced for a client, and another table the dispatch has information on the dispatch details of the product when it gets finished.
If in the process i still do not have have any information on the dispatch yet, and i want to know what is not shipped yet, (by a query) i am not being able to filter the non shipped products from the dispatch table, because it still does not have the record in for the produced products in it yet. so i am wondering if possible, to once a new record is created in the main table, that its related record in other corresponding tables be created automatically

CameronM
02-04-2009, 03:58 PM
If all you want to do is report on the products that do not have a record yet in the dispatch table, you would be better served to use a query, unless you really do want to add every Product as it is created..

The query uses two tables: tblProducts and tblProductDispatch - where ProductID is foreign key field in tblProductDispatch.

Query to show all Products that do not have a record on tblProductDispatch:

SELECT tblProducts.ProductID
FROM tblProducts LEFT JOIN tblProductDispatch ON tblProducts.ProductID = tblProductDispatch.ProductID
WHERE (((tblProductDispatch.DispatchID) Is Null));

Mahoney
02-05-2009, 12:01 AM
Many thanks Cameron, worked great :D