Hi, here is my situation, I have a DB that tracks machine downtime (30 machines) per day. Several users will update this through the day. I created an append query that creates 30 dummy values and then opens up a form that displays all 30 values. The user can then go through these and change the ones they are responsible for. After they have updated this form, i have a delete query that searches for the dummy values and removes them.
My problem is that when a second user comes along and runs the append query it will create duplicate values, for example, if the first user changed 5 machines, when the append query is executed and the form is brought up, there will be 35 values, ie, 5 machines will be listed twice once with the previous users input and once with the dummy values. I would like the append query to search the table for existing values and add new ones only.
My main table is "Data", it contains all the information.
I also have a master table "Machines" that lists all the machines.
My SQL Code for my append query is:
[code=sql]INSERT INTO DATA ( [Machine ID], [Date], [Machine Inuse?], [Downtime Code 1], [Downtime Code 2], [Downtime Code 3], [Downtime Code 4] )
SELECT Machines.Machin e, Forms![Enter Data Form]!Text16 AS Expr1, False AS InUse, 0 AS DT1, 0 AS DT2, 0 AS DT3, 0 AS DT4
FROM Machines
ORDER BY Machines.Machin e;[/code]
My SQL Code for my delete query is:
[code=sql]DELETE Data.[Machine Inuse?], Data.[Downtime Code 1], Data.[Downtime Code 2], Data.[Downtime Code 3], Data.[Downtime Code 4], Data.[Downtime Code 5], Data.Comments
FROM Data
WHERE (((Data.[Machine Inuse?])=False) AND ((Data.[Downtime Code 1])=0) AND ((Data.[Downtime Code 2])=0) AND ((Data.[Downtime Code 3])=0) AND ((Data.[Downtime Code 4])=0) AND ((Data.[Downtime Code 5])=0) AND ((Data.Comments ) Is Null));[/code]
Thanks for your help!
My problem is that when a second user comes along and runs the append query it will create duplicate values, for example, if the first user changed 5 machines, when the append query is executed and the form is brought up, there will be 35 values, ie, 5 machines will be listed twice once with the previous users input and once with the dummy values. I would like the append query to search the table for existing values and add new ones only.
My main table is "Data", it contains all the information.
I also have a master table "Machines" that lists all the machines.
My SQL Code for my append query is:
[code=sql]INSERT INTO DATA ( [Machine ID], [Date], [Machine Inuse?], [Downtime Code 1], [Downtime Code 2], [Downtime Code 3], [Downtime Code 4] )
SELECT Machines.Machin e, Forms![Enter Data Form]!Text16 AS Expr1, False AS InUse, 0 AS DT1, 0 AS DT2, 0 AS DT3, 0 AS DT4
FROM Machines
ORDER BY Machines.Machin e;[/code]
My SQL Code for my delete query is:
[code=sql]DELETE Data.[Machine Inuse?], Data.[Downtime Code 1], Data.[Downtime Code 2], Data.[Downtime Code 3], Data.[Downtime Code 4], Data.[Downtime Code 5], Data.Comments
FROM Data
WHERE (((Data.[Machine Inuse?])=False) AND ((Data.[Downtime Code 1])=0) AND ((Data.[Downtime Code 2])=0) AND ((Data.[Downtime Code 3])=0) AND ((Data.[Downtime Code 4])=0) AND ((Data.[Downtime Code 5])=0) AND ((Data.Comments ) Is Null));[/code]
Thanks for your help!
Comment