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.

If then statement in MS Access?

Okay here's what I have:

Column A: Work Order Number

Column B: Close Date

Column C: System Date

I essentially want to add a column D that is an if then statement saying "If system date is more than 2 days difference from close date, show 'yes', if not show 'no' "

I got it in excel : =IF(C3>(B3+2),"YES","NO") but can't do it in Access!

3 Answers

Relevance
  • Anonymous
    1 decade ago
    Favorite Answer

    In this case you could just make a query. Substitute "Orders" with your table name, and the ColA ColB ColC with your actual column names.

    SELECT *

    FROM Orders

    WHERE (((Orders.ColB)>(Orders.ColC+2)));

  • Anonymous
    1 decade ago

    You'll have to do it in VBA:

    strSQL = INSERT INTO <your table name> ([Work Order Number], [Close Date], [System Date], [<column D's name>] VALUES (<work order number value>, <the close date>, <the system date>,'" & IIF(DateDiff("d",<system date value>, <close date value>) > 2, "yes", "no") & "';"

    Then use strSQL to do the insert.

  • 1 decade ago

    Access uses the VB function "IIF".

    SELECT ( IIF( x > y, "Yes", "No") ) FROM sometable;

Still have questions? Get your answers by asking now.