Results 1 to 6 of 6
  1. #1
    robertr is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    5

    Converting Excel IF to Access iiF???

    Hi - I am stuck on how to create an iif statement in Access that will look at mulitple rows and return the expected vaslues in one column. Here is an example. I appreciate any suggestions. Thanks!



    V2 = Source column
    DE2 = Source Column

    IF(AND(V2="EMP+CHILDREN",DE2="N"),"Tobacco Free Associate + Child(ren)", IF(AND(V2="FAMILY",DE2="Y"),"Associate + Family","Tobacco Free Associate + Family"))

  2. #2
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Assuming that V2 and DE2 are your field names in Access, then this is the formula in a new field:

    =iif([V2]="Emp+children" and [DE2]="N","Tobacco Free Associate + Child(ren)",iif([V2]="Family" and [DE2]="Y","Associate + Family","Tobacco Free Associate + Family"))

    Alan

  3. #3
    robertr is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    5
    Thanks so much!!!

    What about if I want to add to the end a default value/column if the criteria is not satisfied?

  4. #4
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    I am not understanding. Your iif statement false section determines that. What am I missing? Perhaps and example of what you are attempting.

  5. #5
    robertr is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    5
    THIS WORKED GREAT!!

    My question is how do I defer to a desired default column value if the iif statement doe nor return as expected? I added the [PLAN] to the end of the statement but am receiving and error.

    Plans2: IIf([PLAN]="EMP" And [SMOKING]="N","Tobacco Free Associate Only",IIf([PLAN]="EMP+SPOUSE" And [SMOKING]="Y","Associate + Spouse",IIf([PLAN]="EMP+SPOUSE" And [SMOKING]="N","Tobacco Free Associate + Spouse)",IIf([PLAN]="EMP+CHILDREN" And [SMOKING]="Y","Associate + Child(ren)",IIf([PLAN]="Emp+children" And [SMOKING]="N","Tobacco Free Associate + Child(ren)",IIf([PLAN]="Family" And [SMOKING]="Y","Associate + Family","Tobacco Free Associate + Family",[PLAN],)))))

  6. #6
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    You currently have a false result for the last item. You need to replace it with another iif statement with a true result and then make the [PLAN] the false result for it.

    The syntax for an iif statement is =iif(Criteria, Result if True, Result if False)

    You have tried to add a second False statement that Access does not understand.

    Alan

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

Similar Threads

  1. Converting to access from Excel
    By Alexpi in forum Database Design
    Replies: 3
    Last Post: 05-24-2011, 02:46 PM
  2. Converting Excel Macro into Access Module
    By diddyville in forum Modules
    Replies: 1
    Last Post: 03-28-2011, 07:02 PM
  3. Replies: 1
    Last Post: 02-21-2011, 09:55 PM
  4. Export to excel with hyperlink converting
    By Jamy in forum Import/Export Data
    Replies: 0
    Last Post: 03-22-2010, 08:36 AM
  5. Converting or using Access as a front end for Excel
    By jacko311 in forum Database Design
    Replies: 4
    Last Post: 11-07-2009, 12:19 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