Results 1 to 6 of 6
  1. #1
    SilverLining is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2015
    Posts
    3

    Query: Check two fields and pick one value based on Iif statement


    I have two queries that are decoding one field from a table each (table for wildland fires, and table for all the other fires). I should note that I didn't build this original database and I cannot change any of the tables themselves.

    I have a query called Pivot_WildlandB with a field FRWFireCause and another query called Pivot_SummaryB with a field called FireCause. Both those queries feed into a large append query. Currently the large append query displays both FRWFireCause and FireCause. I am trying to build a query that would combine them into one field named Cause. I've tried using an iif statement like this> Cause: Iif(Not IsNull[FRWFireCause] & [FireCause] = "All Other Causes", [FRWFireCause], [FireCause] but it keeps saying expression has invalid syntax and then highlighting the FRWFireCause right after Not IsNull.

    I need the iif statement to return the value in FRWFireCause if FRWFireCause is not null and if FireCause is "All Other Causes". Otherwise, I need the query to return the FireCause value. I've done them before but hitting a brick wall here. Any help would be much appreciated!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Well for starters, IsNull() is a function requiring parentheses:

    IsNull(FieldName)
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    SilverLining is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2015
    Posts
    3
    Thank you Paul. Now it will at least run but it won't return FireCause if the criteria fail. It just puts a blank now. It's also returned FRWFireCause as Cause even if it doesn't meet the "All Other Causes" criteria.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    I suspect you want And rather than &.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    SilverLining is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2015
    Posts
    3
    That solved it! Thank you. The final solution was this

    Cause: IIf(Not IsNull([FRWFireCause]) And [FireCause]="All Other Causes",[FRWFireCause],[FireCause])

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Happy to help and welcome to the site by the way!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 5
    Last Post: 06-26-2014, 12:52 PM
  2. IIF statement based on check box returns #error
    By timmygrover in forum Queries
    Replies: 7
    Last Post: 09-04-2012, 04:41 PM
  3. Replies: 12
    Last Post: 05-07-2012, 12:41 PM
  4. Replies: 3
    Last Post: 01-16-2012, 02:34 PM
  5. How to Query fields with check boxes?
    By JynxRD in forum Queries
    Replies: 2
    Last Post: 09-10-2010, 08:35 PM

Tags for this Thread

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