Results 1 to 3 of 3
  1. #1
    qzst66 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2011
    Posts
    1

    Query: Iff Cell = Cell below same column, then add "Delete"

    Hi, I am new to access. I have a table with duplicate data, i.e. column A has all the purchase order numbers, column B all the dates. I have sorted the table by purchase orders ascending and dates ascending. Now this table has duplicate records. Goal is to have only unique purchase order numbers with the latest date.

    I would like to do a query, that add a column C to my table with the following formula:
    If Cell1 of row 1 = Cell2 of row 2 in column A, then add a word "Delete", otherwise "Keep".



    Output should be like this:

    Column A Column B Column C
    45 11/28/11 Delete
    45 11/30/11 Keep
    46 etc...

    I have been trying with the IFF function, copy the formula from Excel to Access, but it does not work.
    Please help.

  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,930
    Can't do with IIf unless you build a custom VBA function that uses the IIf conditional and then updates table.

    Google: access sql delete duplicate rows

    To do with queries, use DELETE WHERE NOT EXISTS. Review this tutorial http://www.techonthenet.com/sql/delete.php

    Do a Totals query that groups on Purchase order number and returns Max(OrderDate). Use this query as the criteria for the EXISTS clause subquery.

    Here is another approach http://support.microsoft.com/kb/139444
    and more help http://stackoverflow.com/questions/3...licate-records

    Make sure you really want to delete http://office.microsoft.com/en-us/ac...001034558.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.

  3. #3
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529

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

Similar Threads

  1. Replies: 6
    Last Post: 07-25-2012, 06:42 AM
  2. Replies: 11
    Last Post: 03-30-2011, 01:08 PM
  3. Excel Automation Autofit Column (or Cell?) Width
    By orcinus in forum Programming
    Replies: 3
    Last Post: 02-09-2011, 11:44 AM
  4. Replies: 4
    Last Post: 06-14-2010, 02:31 PM
  5. Can we post Access cell data to Excel cell properties?
    By Zethro in forum Import/Export Data
    Replies: 1
    Last Post: 12-13-2005, 08:42 AM

Tags for this Thread

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