473,378 Members | 1,544 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Append Query, duplicates

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:

Expand|Select|Wrap|Line Numbers
  1. INSERT INTO DATA ( [Machine ID], [Date], [Machine Inuse?], [Downtime Code 1], [Downtime Code 2], [Downtime Code 3], [Downtime Code 4] )
  2. SELECT Machines.Machine, Forms![Enter Data Form]!Text16 AS Expr1, False AS InUse, 0 AS DT1, 0 AS DT2, 0 AS DT3, 0 AS DT4
  3. FROM Machines
  4. ORDER BY Machines.Machine;
My SQL Code for my delete query is:
Expand|Select|Wrap|Line Numbers
  1. 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
  2. FROM Data
  3. 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));
Thanks for your help!
Mar 14 '08 #1
4 3350
MindBender77
234 100+
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:

INSERT INTO DATA ( [Machine ID], [Date], [Machine Inuse?], [Downtime Code 1], [Downtime Code 2], [Downtime Code 3], [Downtime Code 4] )
SELECT Machines.Machine, 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.Machine;

My SQL Code for my delete query is:

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));

Thanks for your help!
You could add criteria to your append query that will append only values that are not equal to dummy values.

Bender
Mar 14 '08 #2
I don't quite understand, if i were to only append values that are not equal to my dummy values wouldn't it append everything? because immediately after the form is updated i run a delete query to clear out the dummy values.
Mar 14 '08 #3
Stewart Ross
2,545 Expert Mod 2GB
Hi Scott. Didn't we cover this in your previous thread - http://www.thescripts.com/forum/thread781299.html? If you let multiple users do the append you will end up with duplicates. If this proves a problem you will need to either stop using the append and just go back to adding the machine date lines manually, or use a more complex form of query which does have criteria to exclude such duplicates as Bender said, or set relationships on your tables that prevent duplicates from occurring.

-Stewart
Mar 14 '08 #4
Im looking for a query that searches through the table for machines that have data cooresponding to a specific date, the append query would then disclude that machine.
Mar 14 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: JMCN | last post by:
hi- i have inherited an access 97 database that keeps track of the loans. i have been running into referential intergrity problems when i try to append new loans to table. first of all is a...
3
by: Larry Rekow | last post by:
As part of a macro, I'm trying to automate appending a table with new records. let's say the table 2 has some new records in it, but also has a lot of identical records to table 1. I would...
1
by: strauss.sean | last post by:
To all: Hi! I am trying to use an append queries on a table where the key field is numeric, formatted as 00-00-000. The query collects the information corectly, and there are no records...
7
by: What-a-Tool | last post by:
Remember seeing a post a while back from someone who wanted to add to a table only if the data didn't already exist. Someone suggested a type of query called an "Up" something or other. Can't...
1
by: jpr | last post by:
Friends, I would like some help with a code that allows me to run an append query only if a specific field is not already stored into another table. Example. I add a new customer to my database...
0
by: jon | last post by:
Hi there, I'm brand new to Access and may be trying to do too much too soon, but I wanted to get some expert advice on how the best way to go about what I am trying to accomplish would be. I...
7
by: wade.wall | last post by:
Hi all, I am having a problem appending data to an existing table. I have two tables with identical fields and I want to append the data from one table (T2) to the first (T1). T1 has 136...
3
allingame
by: allingame | last post by:
Need help with append and delete duplicates I have tables namely 1)emp, 2)time and 3)payroll TABLE emp ssn text U]PK name text
4
by: franc sutherland | last post by:
Hello, I am using Access 2003. I am having trouble trapping the "can't append all the records in the append query" error message when appending data to a query from a table which is linked to...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.