Hi, I've two tables:
Dispatch
-----------------------------------------------------------------------
DispatchID | CustomerID | DispatchDate | Service | ConsignmentID
-----------------------------------------------------------------------
1 1 2008-07-04 Zippy AZ432-566
DispatchItem
-----------------------------------------------------------------------
DispatchItemID | DispatchID | OrderItemID | NbrDispatched
-----------------------------------------------------------------------
1 1 1 1
In the above tables: In Dispatch, DispatchID is autonumber and is a primary key, CustomerID is a foreign key and can be repeated, DispatchDate is the date of the dispatch, Service is the name of service used to dispatch items and ConsignmentID is just some ID and can be null.
Similarly, in DispatchItem, DispatchItemID is autonumber and a primary key, DispatchID is a foreign key, OrderItemID is a foreign key and NbrDispatched is the number of item(s) dispatched.
Now, when new items are dispatched I inserted CustomerID, DispatchDate and Service and left the ConsignmentID as it can be null and DispatchID as it increments automatically. Now, the problem I'm facing is, I want to insert details in DispatchItem as well and, no where in the world, I could figure out how I can insert the same DispatchID that got inserted while inserting other details in Dispatch table in DispatchID column in DispatchItem table. Also, I'm wondering how I can include query in insert statement for OrderItemID coz it has to be the one where OrderNbr = ? AND ItemID = ? From other table. I'm using VBA for the insert and update from a form. Thanks.
Dispatch
-----------------------------------------------------------------------
DispatchID | CustomerID | DispatchDate | Service | ConsignmentID
-----------------------------------------------------------------------
1 1 2008-07-04 Zippy AZ432-566
DispatchItem
-----------------------------------------------------------------------
DispatchItemID | DispatchID | OrderItemID | NbrDispatched
-----------------------------------------------------------------------
1 1 1 1
In the above tables: In Dispatch, DispatchID is autonumber and is a primary key, CustomerID is a foreign key and can be repeated, DispatchDate is the date of the dispatch, Service is the name of service used to dispatch items and ConsignmentID is just some ID and can be null.
Similarly, in DispatchItem, DispatchItemID is autonumber and a primary key, DispatchID is a foreign key, OrderItemID is a foreign key and NbrDispatched is the number of item(s) dispatched.
Now, when new items are dispatched I inserted CustomerID, DispatchDate and Service and left the ConsignmentID as it can be null and DispatchID as it increments automatically. Now, the problem I'm facing is, I want to insert details in DispatchItem as well and, no where in the world, I could figure out how I can insert the same DispatchID that got inserted while inserting other details in Dispatch table in DispatchID column in DispatchItem table. Also, I'm wondering how I can include query in insert statement for OrderItemID coz it has to be the one where OrderNbr = ? AND ItemID = ? From other table. I'm using VBA for the insert and update from a form. Thanks.