Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Access 2007 IIF or If Else?

I am trying to run a query for a report that will pull the value of a Field when the checkbox is selected (-1) or nothing if it is not checked. I can't seem to get the syntax right to pull the needed information and I'm not sure if I should use and IIF or If else in VBA. Any recommendations?

Sample IIF that isn't working:

IIf([question2_check]='-1',

'[question2]','Null')

Update:

The problem is I am returning the value to 4 check fields. If you use a where statement it will pull values for all fields listed. The query below returns values for each column which I only want -1 responses.

SELECT Survey_Feed.[Session_ID], Survey_Feed.[Submit_Time], Survey_Feed.[Question2], Survey_Feed.Question5

FROM Survey_Feed

WHERE (([Question2_check]='-1')) OR (([Question5_check]='-1'));

1 Answer

Relevance
  • 1 decade ago
    Favorite Answer

    There is no need for an IIFstatement. The WHERE clause of the query will filter out the records which don't satisfy the criteria.

    SELECT yourtable.question2_check, yourtable.question2

    FROM yourtable

    WHERE question2_check=-1;

Still have questions? Get your answers by asking now.