Results 1 to 4 of 4
  1. #1
    Hello World is offline Novice
    Windows XP Access 2002
    Join Date
    Sep 2011
    Posts
    13

    Query (if Statement I Think?)


    I have a table with these two fields: ‘Answer’ and ‘RevisedAnswer’. Both draw their values from the same look-up.

    Hi,

    I have some data in each field in a table which looks something like this. Both draw their values from the same look-up.

    FirstAnswer RevisedAnswer

    1. Yes No
    2. No
    3. No Yes
    4. No Yes
    5. Yes

    What I would like to do is have a report which reports on the latest state of play regarding how people have answered (how many people have said yes or no). But crucially if people have revised their answer then I need this to take precedence over their first answer. For example the final report on the above would state that 2 people have said ‘No’ and 3 people have said ‘Yes’.

    I suppose what I require is some code which states that if the first answer column has data in it and the revised answer column is null then take the first answer column BUT if both fields have data in them then take the revised answer column.

    Ultimately I would like the query to count how many people have said yes or no.

    Hoping that makes sense.

  2. #2
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481
    Create a query which includes both columns, then add a calculated column (FnlAnsr) which is a if statement. After you test that query, then add the totals.

  3. #3
    Hello World is offline Novice
    Windows XP Access 2002
    Join Date
    Sep 2011
    Posts
    13
    Thanks Hertford,

    Any idea what that If statmenet would be?

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    iif(not isnull(revisedanswer), revisedanswer, firstanswer)

    This will give you the revised answer if it's present, otherwise it will give you the first answer.

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

Similar Threads

  1. query iif statement help
    By swat in forum Queries
    Replies: 4
    Last Post: 09-30-2011, 11:48 AM
  2. Query/IiF statement
    By peacepower in forum Queries
    Replies: 1
    Last Post: 08-23-2011, 04:05 PM
  3. Help fix SQL Statement for query
    By Budro49 in forum Queries
    Replies: 12
    Last Post: 06-21-2011, 02:26 PM
  4. I need help writing a query statement
    By dking in forum Queries
    Replies: 1
    Last Post: 02-25-2009, 09:43 AM
  5. If then statement in query
    By ronnie4 in forum Queries
    Replies: 1
    Last Post: 01-20-2009, 10:49 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