473,398 Members | 2,404 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,398 software developers and data experts.

Append Query generates duplicate entries

Hi guys. I am using an Append Query to add records to an Archive Table in an MS Access Application. The code generates 2 records for each one identified.

Expand|Select|Wrap|Line Numbers
  1. strSQLAppend(1) = "INSERT INTO Timings_Archive " & _
  2.                   "SELECT Timings.Record,Timings.Activity_Nr, Timings.Owner, Timings.Role,Timings.Category,Timings.[Sub-Category],Timings.Comments,Timings.[Start Time],Timings.[End Time],Timings.[Total Time],Timings.Overwrite,Timings.[Enter Date],Timings.[Effective Date]" & _
  3.                    "FROM Timings INNER JOIN Activities_Archive " & _
  4.                    "ON Timings.Activity_Nr = Activities_Archive.Activity_Nr;"
  5.  
  6. CurrentDb.Execute strSQLAppend(1), dbFailOnError
May 22 '15 #1

✓ answered by jforbes

Yep, there are probably two records in Activities_Archive that match the join.

9 2387
Rabbit
12,516 Expert Mod 8TB
Your thread has been moved to the Access forum.

Please use code tags when posting code or formatted data.

Why are you joining to activities_archive? You're not selecting or filtering on anything in that table.
May 22 '15 #2
jforbes
1,107 Expert 1GB
Yep, there are probably two records in Activities_Archive that match the join.
May 22 '15 #3
that's what is interesting. The records in the Activities_Archive are unique, but the query generates two records for each record matched. If there are multiple Timings Records associated an Activity then 2 records are generated for each one.
May 22 '15 #4
Well.... I guess I did generate multiple duplicate entries in the Activities_Archive when testing. Thanks for the assist.
May 22 '15 #5
jforbes
1,107 Expert 1GB
That's normal functionality for an Inner Join. If you only want one record from the Timings_Archive then you could use a Left Join, otherwise you will get a record for each match for both tables.

Like Rabbit, to me, the join to Activities_Archive when you aren't selecting any values from the Table is seems a bit odd. But I'm not really sure what you are attempting to accomplish.
May 23 '15 #6
NeoPa
32,556 Expert Mod 16PB
JForbes:
If you only want one record from the Timings_Archive then you could use a Left Join
I'm not sure where you're going with that one. I don't believe that will help. To ensure no duplicates are involved you would need to ensure there is only one (or none would also work for a LEFT JOIN) record that matches from the table JOINed to.
May 23 '15 #7
jforbes
1,107 Expert 1GB
Good catch, Timings_Archive was a typo. I meant Timings:
Expand|Select|Wrap|Line Numbers
  1. FROM Timings LEFT JOIN Activities_Archive 
I'm not saying it is right as I'm not really sure what the goal is here, but the Select would return only one record per Timings Record.
May 24 '15 #8
NeoPa
32,556 Expert Mod 16PB
JForbes:
... but the Select would return only one record per Timings Record.
I'm afraid that is not guaranteed at all. If there were more than one matching [Activities_Archive] record then there would be an output record for each. That was the point I was attempting to make earlier.

The easiest thing to do is to try it out for yourself, but there's supporting info at SQL JOINs.
May 24 '15 #9
jforbes
1,107 Expert 1GB
Holy cow, I'm not sure how I got turned around on that. Please ignore anything I said about Left Joins as it is way wrong.
May 25 '15 #10

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

Similar topics

5
by: Manish | last post by:
The topic is related to MySQL database. Suppose a table "address" contains the following records ------------------------------------------------------- | name | address | phone |...
1
by: James Hallam | last post by:
I have a form with a subform. When there are no entries in the subform, I have an append query which makes a default entry in the subform (for what I am doing there needs to be at least one value...
4
by: Scott12345 | last post by:
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...
7
by: php_mysql_beginer911 | last post by:
Hi .. i am trying to update a table where if field contents any duplictaed entries than one of the field should be updated with random number which is unique so i can make all entries unique i...
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...
2
by: David Shears | last post by:
I am trying to use an append query to add data to another table i have. I have tableA and tableB. tableA has 1000 rows while tableB has 800 rows. i would like to add the other 200 rows in tableA to...
5
Fspinelli
by: Fspinelli | last post by:
I have an append query which takes data from a query and updates a table. However, instead of one record I get 3 or 4 of the same records dumped into the table. I might enter three records, press...
8
by: prose01 | last post by:
I was able to create a multiple field unique index for the EI&Fees table, restricting to unique values for FacilityId, EmissionInvYear, and FeeYear; however, can you show me how to apply the same...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.