Results 1 to 3 of 3
  1. #1
    LilMissAttack is offline Novice
    Windows XP Access 2007
    Join Date
    May 2010
    Posts
    26

    IIF statement

    Hi, I'm trying to pull something based on conditions. If the first zipcode field is blank, I want it to pull the 2nd, if that is blank I want it to move to a 3rd. It isn't pulling the 3rd option, here is what I have..what am I missing here? Thanks!

    ZipCode:IIf(IsNull([dbo_query_Sales_Order_Delivery_Address_sls042]![Zipcode]),


    [dbo_query_Delivery_Addresses]![Postcode],IIf(IsNull([dbo_query_Delivery_Addresses]![Postcode]),
    [dbo_query_Customer_Master]![PostCode],[dbo_query_Sales_Order_Delivery_Address_sls042]![Zipcode]))

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Try:

    Nz([dbo_query_Sales_Order_Delivery_Address_sls042]![Zipcode],
    Nz([dbo_query_Delivery_Addresses]![Postcode],
    [dbo_query_Customer_Master]![PostCode]))

    EDIT: I like rpeare's concatenation suggestion from the next post. Like Of Course, Duh!
    Last edited by June7; 08-05-2011 at 11:17 AM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Your iif statement is circular and not logically doing what you want.

    For instance let's say this part of your statement evalutes as true (the item is null

    IIf(IsNull([dbo_query_Delivery_Addresses]![Postcode])

    You are automatically making it use

    [dbo_query_Customer_Master]![PostCode]

    which makes me ask this:

    Is only ONE postal code going to be available? Or is there the possibility of there being a postal code in each field? If so is your priority

    dbo_query_Sales_Order_Delivery_Address_sls042
    THEN
    dbo_query_Delivery_Addresses
    THEN
    dbo_query_Customer_Master

    if only one will be active I'd do something like this

    ZipCode: [dbo_query_Sales_Order_Delivery_Address_sls042]![Zipcode] &
    [dbo_query_Delivery_Addresses]![Postcode] & [dbo_query_Customer_Master]![PostCode]

    What this is going to do is append 3 different strings together and if 2 of the three strings are null you won't even notice them.

    If you're doing a priority system it's a little more complex

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

Similar Threads

  1. If Statement Help
    By vennies83 in forum Queries
    Replies: 1
    Last Post: 06-09-2011, 03:50 PM
  2. BETWEEN in a FROM Statement
    By Cyborg in forum Queries
    Replies: 6
    Last Post: 05-12-2011, 01:54 PM
  3. If Statement
    By ajolson1964 in forum Access
    Replies: 1
    Last Post: 05-11-2011, 07:51 AM
  4. need a If /then statement
    By kmiszczak in forum Access
    Replies: 1
    Last Post: 04-12-2011, 01:51 PM
  5. for each statement in vba
    By tuyo in forum Access
    Replies: 0
    Last Post: 03-22-2011, 05:42 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