Results 1 to 3 of 3
  1. #1
    fluffyvampirekitten is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Posts
    108

    If statement in query - criteria help!

    I have a table of Duplicates data .


    ID | Name
    1 | Teddy
    1 | Ted
    2 | Ben
    2 | Ben
    3 | Pinky
    3 | Pinky

    I would like to extract the data which have different Names but have the same ID
    Result:

    ID | Name
    1 | Teddy
    1 | Ted

    Any idea to do it in a query or vba ?



    if id = id
    if name != name
    display data
    else
    do nothing
    end if
    else


    do nothing
    end if

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    I made up the table name tblPeeps, and since Name is a reserved word in Access I used pName.
    This should give you a good start.
    Code:
    SELECT count(tblPeeps.ID), tblPeeps.pname
    FROM tblPeeps 
    group by pname
    having count(tblPeeps.ID) <2

  3. #3
    fluffyvampirekitten is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Posts
    108
    Quote Originally Posted by orange View Post
    I made up the table name tblPeeps, and since Name is a reserved word in Access I used pName.
    This should give you a good start.
    Code:
    SELECT count(tblPeeps.ID), tblPeeps.pname
    FROM tblPeeps 
    group by pname
    having count(tblPeeps.ID) <2
    Omg. Thank you so much

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

Similar Threads

  1. Replies: 2
    Last Post: 10-20-2015, 02:01 PM
  2. IIF Statement with OR criteria
    By McArthurGDM in forum Queries
    Replies: 8
    Last Post: 03-16-2015, 05:01 PM
  3. If then statement using Yes/No criteria
    By jpiazza in forum Macros
    Replies: 5
    Last Post: 07-12-2014, 11:06 PM
  4. Replies: 5
    Last Post: 07-02-2014, 07:13 AM
  5. IIf Statement in Query Criteria
    By kyle87 in forum Queries
    Replies: 8
    Last Post: 07-29-2013, 12:31 PM

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