I am trying to update a field inside one table, "Todays_Deliveries", from another table called "Current_Delivery". The field is a number field called "Remaining" which describes how many units there are of a particular item left on the daily deliveries.
The "Todays_Deliveries" table is generated using an APPEND query from another master table with every delivery stored in it. Everytime the user opens a delivery on a form anything in the "Current_Delivery" table is removed using a DELETE query and then generated based on the delivery selected using an APPEND query from the "Todays_Deliveries" table.
Both tables have identical fields and identical values, given one is generated from the data of the other.
I have tried to create an UPDATE query to update the "Todays_Deliveries" table when a user edits the "Current_Delivery" table but it doesn't work. I recieve no error messages the field just doesn't update. The steps I took were as follows:
- Add both tables.
- Change to UPDATE query.
- Link tables using the Remaining field.
- Set the Field: Remaining and
- Set the Table: Current_Delivery.
- Set Update To: [Todays_Deliveries].[Remaining].
Any advice/help would be greatly appreciated.
EDIT:
BEFORE:
Todays_Deliveries
ID Date Time Ref Studio Description Total Remaining
3187 23-Oct-12 10:00 3663 ROCK PINK 1900 1900
Current_Delivery
ID Date Time Ref Studio Description Total Remaining
3187 23-Oct-12 10:00 3663 ROCK PINK 1900 1000
AFTER:
Todays_Deliveries
ID Date Time Ref Studio Description Total Remaining
3187 23-Oct-12 10:00 3663 ROCK PINK 1900 1000
UPDATE:
I've got the query working using the below function
UPDATE Todays_Deliveries SET Remaining = DLookup("Remaining","Current_Delivery","[MP-Ref] = Form![MP-Ref] And [Cat No] ='" & [Cat No] & "'")
WHERE "[MP-Ref] = Form![MP-Ref] And [Cat No] ='" & [Cat No] & "'";
Where MP-Ref is the delivery reference that list a number of items, and Cat No is the individual item reference.
The only problem is the other items in the _Daily_Deliveries_ table, the ones not in the _Current_Delivery_ table, have there remaining field set to 0 when I run it. Is there anyway to stop this?