Results 1 to 6 of 6
  1. #1
    jo15765's Avatar
    jo15765 is offline Expert
    Windows XP Access 2000
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    672

    IIF With Nested IIF?

    I need to check table AD and check if field CG is null, if it is I need to check if the AD.CI exists in my table SSCG.id, if it does I want to update AD.CG with the value in SSCG.dpt IF AD.CI does NOT exist in SSCG.id, then I want to update AD.CG with the value in SSC.alpha.

    If I need to provide data structure/join conditions I can, but this may help



    This is pseudocode of what I want to execute
    Code:
    if [AD].[CG] IS NULL 
    if [AD].[CI] Exists in [SSCG].[id] then [SSCG].[dpt]
    else [SSC].[alpha]

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Perhaps it would be better to do the validation and any other necessary entries when the original record is created
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,732
    Just curious -- why do you have such cryptic names? Do you really enjoy coding with all the square brackets?

    In addition to Bob's suggestion, I think it would be useful to readers, and better for your getting focused responses, if you could describe your "database and/or business opportunity" in plain English.

    Good luck.

  4. #4
    jo15765's Avatar
    jo15765 is offline Expert
    Windows XP Access 2000
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    672
    Quote Originally Posted by Bob Fitz View Post
    Perhaps it would be better to do the validation and any other necessary entries when the original record is created
    Unfortunately, fixing it on the front end is not an option. We received 3 Excel files and are attempting to merge into one database table and that is the business rule that needs to be applied.

  5. #5
    jo15765's Avatar
    jo15765 is offline Expert
    Windows XP Access 2000
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    672
    Quote Originally Posted by orange View Post
    Just curious -- why do you have such cryptic names? Do you really enjoy coding with all the square brackets?

    In addition to Bob's suggestion, I think it would be useful to readers, and better for your getting focused responses, if you could describe your "database and/or business opportunity" in plain English.

    Good luck.
    It may look cryptic but those are actually abbreviations for internal metrics/tables that we use. For example (again may not make sense to someone else) this is what the tables/field names actually equate to, and based off internal business rules is how I was trying to set up the iif statement
    Code:
    AD = Alpha Domingo
    CG = Consumer Grid
    SSCG = Steve Sacos Consumer Grid 
    dpt = data point
    SSC = Sara Smiths Consumer
    Alpha = Alpha

  6. #6
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,732
    Interesting. Show a jpg of your tables and relationships-- make sure tables are expanded so we can see all fields.

    Yes, they are cryptic-- much like the old Fortran days---you know x, x1, x2 and y....

    As for
    We received 3 Excel files and are attempting to merge into one database table and that is the business rule that needs to be applied.
    the typical approach sis to bring the excel data into a temporary table, then using queries or code, pick out the fields and combinations and update your "final table". Excel files/sheets are not normalized generally,but hopefully your database is.
    That my be the essence of your problems, but we need some description that makes sense -outside your internal metrics/tables.

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

Similar Threads

  1. Nested IF
    By balajigade in forum Queries
    Replies: 3
    Last Post: 10-04-2014, 10:23 AM
  2. nested iif
    By slimjen in forum Reports
    Replies: 1
    Last Post: 03-15-2014, 09:30 AM
  3. Nested And/Or query
    By kagoodwin13 in forum Queries
    Replies: 2
    Last Post: 05-10-2012, 12:10 PM
  4. Nested IIF
    By Oldie in forum Queries
    Replies: 1
    Last Post: 02-17-2012, 06:04 AM
  5. Nested IIf Statement
    By traquino98 in forum Queries
    Replies: 5
    Last Post: 06-11-2011, 10:56 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