Results 1 to 2 of 2
  1. #1
    bradley4681 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2012
    Posts
    1

    Combine two fields and update table only when duplicates exist in source field

    So I apologize in advanced if I describing anything wrong. I generally have only lurked to hack together the queries I've needed. I just can't seem to get this one together and I feel like I'm close. I've been at this for days...




    I have a list of Items that have an Item number and a manufacturer number. Some manufacturers have the same number for a few different items so I need to combine the manufacturer number with the item number to make a unique manufacturer number for our system to except.

    Example of Existing
    Part Item MFRnum MFR
    black widget widblk wid200 Acme
    white widget widwht wid200 Acme
    spocket spck1 spck14 Spacely Sprockets
    spocket spck2 spck15 Spacely Sprockets



    Example of what I'm trying to do
    Example of Existing
    Part Item MFRnum MFR
    black widget widblk wid200_widblk Acme
    white widget widwht wid200_widwht Acme
    spocket spck1 spck14 Spacely Sprockets
    spocket spck2 spck15 Spacely Sprockets



    I have a query that will go through the table and find the parts with duplicate manufacturer numbers but I can't seem to rewrite it any way to update the original table only when finding matching numbers.

    Code:
    SELECT FILTERED.Item, FILTERED.MFRnum, MFRnum+"_"+Item AS DupMFR
    FROM FILTERED
    WHERE (((FILTERED.MFRnum) In (SELECT [MFRnum] FROM [FILTERED] As Tmp GROUP BY [MFRnum] HAVING Count(*)>1 )));
    The table name is called FILTERED with more fields then in the example tables above.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    You will have to do a subquery that counts the MFRNum for each MFR/Item/MFRNum then update the records in the table that match the records in the count query that have count greater than 1. Review this http://office.microsoft.com/en-ca/ac...005188710.aspx
    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.

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

Similar Threads

  1. Replies: 3
    Last Post: 08-31-2011, 09:37 AM
  2. Replies: 3
    Last Post: 12-14-2010, 08:35 AM
  3. Combine one item fields in one field
    By romadm in forum Reports
    Replies: 7
    Last Post: 06-04-2010, 11:09 PM
  4. Replies: 3
    Last Post: 08-02-2009, 03:52 PM
  5. Replies: 1
    Last Post: 08-04-2008, 03:30 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