Results 1 to 5 of 5
  1. #1
    erikjhayes is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Sep 2014
    Posts
    3

    Duplicates that meet other criteria

    Hello,

    I am having trouble figuring out how to build a query for what I need. I have a single table with the following fields

    ID (auto number)
    Item_Type
    Serial_Number
    Location

    With data entries like the following



    Item_Type Serial_Number Location
    Chair 12345 Storage
    Chair 6789 xfer out
    Chair 6789 xfer in
    Chair 12345 xfer out
    Chair 22222 storage

    What I need to do is build a query that will identify the duplicates by serial number but only return the records where one of the duplicate serial numbers has a location of storage. So out of the above example it should return

    Item_Type Serial_Number Location
    Chair 12345 Storage
    Chair 12345 xfer out

    Any help would be greatly appreciated.

  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,770
    Domain aggregates can probably get that:

    SELECT *
    FROM table1
    WHERE (((DLookUp("Location","table1","Serial_Number=" & [Serial_Number])="Storage")=True) AND ((DCount("Serial_Number","table1","Serial_Number=" & [Serial_Number]))>1));

    Is Serial_Number a number type field?
    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
    erikjhayes is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Sep 2014
    Posts
    3
    Good morning June7,

    Thank you for the reply. Serial_Number is a text field as actual serial numbers can very in length and format. I tried the code you provided and received a "Syntax error (missing operator) in query expression 'Serial_Number=201CJZ3166' " error. This is one of the serial numbers in the table.

    Thank you for the help.

  4. #4
    erikjhayes is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Sep 2014
    Posts
    3

    db attached

    I have attached the db to hopefully make it easier.

    Thank you.
    Attached Files Attached Files

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    If Serial_Number is a text field, then modify the expressions to include apostrophe delimiters for the parameter.

    "Serial_Number='" & [Serial_Number] & "'")

    DateTime field would use # for parameters.
    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: 1
    Last Post: 03-02-2014, 03:25 PM
  2. Only show records that meet criteria
    By RussH in forum Reports
    Replies: 9
    Last Post: 04-10-2013, 05:25 AM
  3. Query for records that do not meet criteria
    By survivo01 in forum Queries
    Replies: 3
    Last Post: 12-16-2012, 05:45 PM
  4. Replies: 2
    Last Post: 11-28-2012, 10:47 AM
  5. Summing when no records meet criteria
    By clew3 in forum Queries
    Replies: 6
    Last Post: 11-05-2012, 11:37 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