Results 1 to 6 of 6
  1. #1
    accessnewbie352 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2015
    Posts
    46

    IIF Function - Returning Extra Rows

    I am trying to build an expression using the IIF function in a simple query to calculate only if the IIF function = true.




    For example, IIF([Business]="AeroTM",([Total EE]/[Total Dept]),"")


    This views me 2 rows of returned data, 1 row will consist of the calculated value and the next row shows the business again, but shows everything else blank (below is what i see in the datasheet view):



    Business EE/Dept
    AeroTM
    AeroTM 42



    I know this is because in the IIF function, I have said to return "" if the business does not match. Is there a way I can prevent the blank row from happening by either rewriting the IFF function or by doing something else?


    I am new to Access so really only know how to write simple queries.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    That makes no sense. A calculated field does not create records. The records must exist but the calculation results in null probably because one or both of the referenced fields are null. Arithmetic with Null results in Null. Post the full SQL statement of the query.
    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
    A S MANN is offline Advanced System Analyst
    Windows XP Access 2007
    Join Date
    Oct 2010
    Location
    India
    Posts
    161
    Try this
    EE/Dept:
    IIF([Business] Like "AeroTM",(Val([Total EE])/Val*([Total Dept])),0)

  4. #4
    accessnewbie352 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2015
    Posts
    46
    It didn't work - it just returned the extra rows with 0 instead of blanks

  5. #5
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    Dubai
    Posts
    614
    Can't you use "AeroTM" in the criteria section of the [Business] field and the expression [Total EE]/[Total Dept] as a calculated field in your query ?

  6. #6
    accessnewbie352 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2015
    Posts
    46
    Actually I figured out I can do a crosstab query for my need and then did a form off of it. I now am having an issue with formatting the values of my form but will post this in the form thread. Thank you

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

Similar Threads

  1. Replies: 4
    Last Post: 12-22-2014, 08:48 PM
  2. Importing Excel File - Getting 7 extra blank rows each import
    By eking002 in forum Import/Export Data
    Replies: 4
    Last Post: 06-13-2013, 09:15 AM
  3. query returning extra items
    By cbrsix in forum Queries
    Replies: 6
    Last Post: 07-05-2011, 02:22 PM
  4. record set not returning rows
    By lvmoore in forum Forms
    Replies: 3
    Last Post: 09-25-2010, 10:48 AM
  5. Returning correct rows in a join/nested query
    By goneaccessing in forum Queries
    Replies: 5
    Last Post: 03-03-2010, 12:21 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