Results 1 to 2 of 2
  1. #1
    Sayshelz is offline Novice
    Windows XP Access 2003
    Join Date
    Sep 2012
    Posts
    1

    Iif statment in query for multiple fields

    I am having trouble sorting this out.
    These are the fields from a query I wrote:

    Note ID
    Provider Name
    Cosigner Name
    Cosigner Flag (this is an expression from another query: Iif(IsNull([Cosigner Name]),"0","1")

    Note Id Provider Name Cosigner Name Cosigner flag
    1234 Dr. Resident 0


    1234 Dr. Resident Dr. Attending 1
    3456 Dr. Resident 0

    What I need next is a query that will show me a distinct listing of Note ID's, but only if....the note ID has a cosigner flag =1, and if that isn't true, then show me the note ID for the cosigner flag = 0. So, if there is a cosigner show me that row, otherwise show me the row with a zero. Based on the 3 records above I would only expect to see:

    Note Id Provider Name Cosigner Name Cosigner flag
    1234 Dr. Resident Dr. Attending 1
    3456 Dr. Resident 0

    Thank you in advance for any help!!

  2. #2
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Try this query

    SELECT DISTINCT [note id] AS Expr1, YourTableName.[Provider Name], IIf([Cosigner Flag]="0","",[Cosigner Name] & " 1") AS Expr2
    FROM YourTableName;

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

Similar Threads

  1. if statment or case statment?
    By whojstall11 in forum Forms
    Replies: 4
    Last Post: 07-09-2012, 01:44 PM
  2. Adding multiple SQL Statment to code
    By rlsublime in forum Programming
    Replies: 1
    Last Post: 06-20-2012, 01:22 PM
  3. Replies: 12
    Last Post: 05-07-2012, 12:41 PM
  4. SUM Multiple fields in a query
    By Thoudus in forum Queries
    Replies: 3
    Last Post: 02-24-2011, 09:11 AM
  5. Replies: 1
    Last Post: 06-28-2010, 11:04 PM

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