Results 1 to 3 of 3
  1. #1
    tanyalee123 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Oct 2013
    Posts
    51

    Question Importing without Duplicates-What am I doing wrong?

    I am doing something wrong here...


    I have a DB that I need to update with new data. The spreadsheet that I am using to update the database contains data that is already in the DB and data that is new. Here's what I have done, and it's not working...

    I created an append query. Using the QBE, I added the spreadsheet table. I pulled in all of the fields from the spreadsheet. My unique field is SSN (social security number). I created a left join from the spreadsheet (Eligibility) to the table in the DB that I want to update (Eligible_Participants). When I run the query, it attempts to update ALL of my records, not just the new ones. (Unfortunately I don't know how many "new" records there are, but there probably isn't more than a couple hundred at the very most). Here is what the SQL code looks like, in case that helps. I need to figure this out! Every month I need to update this database with our new members. Help please! (I do not want to write over existing data in my DB in case someone has changed data for an existing member, like address, phone number, etc.)

    INSERT INTO Eligible_Participants ( SSN, UniqueID, Alias, PropertyName, Plan, RelCode, FirstName, LastName, Address, City, State, Zip, Phone, BirthDate, Age, Lang, Email, TermDate )
    SELECT DISTINCT Eligibility.SSN, Eligibility.UniqueID, Eligibility.Alias, Eligibility.PropertyName, Eligibility.Plan, Eligibility.RelCode, Eligibility.FirstName, Eligibility.LastName, Eligibility.Address, Eligibility.City, Eligibility.State, Eligibility.Zip, Eligibility.Phone, Eligibility.BirthDate, Eligibility.Age, Eligibility.Lang, Eligibility.Email, Eligibility.TermDate
    FROM Eligibility LEFT JOIN Eligible_Participants ON Eligibility.SSN = Eligible_Participants.SSN
    WHERE (((Eligibility.RelCode)="FM1" Or (Eligibility.RelCode)="MM1"));

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    This already shows as Solved. Is it?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    tanyalee123 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Oct 2013
    Posts
    51
    Oopps for some reason my earlier post didn't show - I had posted that I figured it out. In case anyone was reading it, I figured out to put "Is Null" as criteria for my SSN field in my Eligible_Participants table so the query would not append to records that already had a SSN in it.

    INSERT INTO Eligible_Participants ( SSN, UniqueID, Alias, PropertyName, Plan, RelCode, FirstName, LastName, Address, City, State, Zip, Phone, BirthDate, Age, Lang, Email, TermDate )
    SELECT Eligibility.SSN, Eligibility.UniqueID, Eligibility.Alias, Eligibility.PropertyName, Eligibility.Plan, Eligibility.RelCode, Eligibility.FirstName, Eligibility.LastName, Eligibility.Address, Eligibility.City, Eligibility.State, Eligibility.Zip, Eligibility.Phone, Eligibility.BirthDate, Eligibility.Age, Eligibility.Lang, Eligibility.Email, Eligibility.TermDate
    FROM Eligibility LEFT JOIN Eligible_Participants ON Eligibility.SSN = Eligible_Participants.SSN
    WHERE (((Eligible_Participants.SSN) Is Null))
    GROUP BY Eligibility.SSN, Eligibility.UniqueID, Eligibility.Alias, Eligibility.PropertyName, Eligibility.Plan, Eligibility.RelCode, Eligibility.FirstName, Eligibility.LastName, Eligibility.Address, Eligibility.City, Eligibility.State, Eligibility.Zip, Eligibility.Phone, Eligibility.BirthDate, Eligibility.Age, Eligibility.Lang, Eligibility.Email, Eligibility.TermDate
    HAVING (((Eligibility.RelCode) In ("FM1","MM1")));

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 06-28-2013, 03:12 PM
  2. Replies: 2
    Last Post: 07-12-2012, 12:46 AM
  3. Transferspread sheet importing some WRONG values! WHAT?!
    By qwerty1 in forum Import/Export Data
    Replies: 1
    Last Post: 06-06-2012, 01:32 PM
  4. What is wrong with this IFF?
    By bburton in forum Reports
    Replies: 2
    Last Post: 03-16-2011, 10:42 AM
  5. What am I doing wrong?
    By brandon in forum Access
    Replies: 2
    Last Post: 08-03-2008, 10:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums