Results 1 to 8 of 8
  1. #1
    AudiA4_20T is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2011
    Posts
    28

    Running a query with an "if/than" filter

    Hello everyone,

    First off, how do I donate to this site? It's helped me tremendously at work and I absolutely want to throw a few bucks in.

    Ok, so I have a spreadsheet with (2) different columns of "Name" from 2 sources. I want to run a query to say "If column #1 is N/A, display column 2. If column #2 is N/A, filter out"



    How do I write that into the query and what type do I use?

    TIA!
    Last edited by AudiA4_20T; 06-08-2012 at 07:57 AM.

  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,521
    Along the lines of

    IIf(Column1 = "N/A", Column2, Column1)

    More info in help on the IIf() function. You might also find Switch() appropriate.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    AudiA4_20T is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2011
    Posts
    28
    nvm got it

  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,521
    For starters, you've "simplified" it to an invalid syntax; the IIf() function has 3 parts to it.

    Second, I wouldn't see that as a criteria. I intended it as a new field in the query. Can you describe what you're trying to accomplish?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    AudiA4_20T is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2011
    Posts
    28
    Quote Originally Posted by pbaldy View Post
    For starters, you've "simplified" it to an invalid syntax; the IIf() function has 3 parts to it.

    Second, I wouldn't see that as a criteria. I intended it as a new field in the query. Can you describe what you're trying to accomplish?

    Ok, I'm trying to think of where I'm going wrong here.

    1. I have 2 spreadsheets and I want to update data from spreadsheet 2 to spreadsheet 1.
    2. Spreadsheet 1 already is about 50% filled
    3. I want to ONLY update the ones that are NOT filled in spreadsheet 1.

    So, have something that looks like this

    Field: TownID
    Table: Finance Shell
    Update To: [Assets060612].[TownID]
    Criteria: see below

    so for Criteria, I first though:

    1. "Is Null" in my mind that would mean to ONLY update it if there was no information in there. Well that keeps giving me 0 records which is not true.
    2. "IIF([Finance Shell].[Town])=Null" but that's not working. I know I have some syntax wrong

  6. #6
    AudiA4_20T is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2011
    Posts
    28
    Ok I realized it wasn't Null it said "Unallocated"

    so I changed it to

    IIf([Finance Shell].[Town ID]="Unallocated",[Assets060612].[City],[Finance Shell].[Town ID])

  7. #7
    AudiA4_20T is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2011
    Posts
    28
    Now I'm trying another one here updating data in its own spreadsheet, but it's not updating

    IIf([Username]=Null,[VZW Put Together],[Username])

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I don't work with linked spreadsheets much. Typically an update query with a criteria would be the solution:

    UPDATE TableName
    SET FieldName = Whatever
    WHERE SomeField Is Null
    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: 1
    Last Post: 05-23-2012, 10:05 AM
  2. Replies: 11
    Last Post: 03-29-2012, 02:32 PM
  3. Query Design to Filter datas "in between"
    By nizam in forum Queries
    Replies: 8
    Last Post: 08-04-2011, 01:26 PM
  4. How to Filter When Using The "Create E-Mail" Wizard
    By MFriend in forum Import/Export Data
    Replies: 3
    Last Post: 07-16-2010, 09:45 AM
  5. Create "reset filter" button
    By vanlanjl in forum Access
    Replies: 0
    Last Post: 03-03-2009, 07:36 AM

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