Results 1 to 3 of 3
  1. #1
    gap is offline Novice
    Windows Vista Access 2007
    Join Date
    Jul 2011
    Posts
    12

    Nz or IIF for problems with NULL

    Hi,
    not easy to explain, but a try:
    I want to get the difference in % between the values of two columns of different tables. There are some fields with NULL and often occurs an error in the result fields where was a NULL. Its more complicated because its part of a left join.

    So I think a solution is a combination of NZ and IIF but I am not sure how to use.

    Here an example table:

    Theme | Number_A |Number_B|

    biology | NULL |98
    chemistry | NuLL | 34


    physics |12 | 15
    molecular | 17 | NULL
    nothing | NULL | NULL

    Thanks for some hints,
    gap

  2. #2
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536
    In the QBE, for the fields Number_A and other create an expression as follows:

    NumberA:NZ(tablename.Number_A,0)

    This will change your field name to NumberA versus Number_A and if any record in that field is null then it will present it as a zero.

    Alan

  3. #3
    gap is offline Novice
    Windows Vista Access 2007
    Join Date
    Jul 2011
    Posts
    12
    Got it,
    I am using NZ([NumberA], 0) - NZ([NumberB], 0)....... AS Differenz
    The important point was to use the UNION because in access there is no FULL JOIN I just could use the LEFT JOIN. Its getting a very complex query, but is working!

    If there is a nicer way...please post.
    (But I think I have to start VBA..)

    gap

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

Similar Threads

  1. Is Null
    By 1943 in forum Access
    Replies: 3
    Last Post: 02-21-2011, 02:33 PM
  2. Invalid use of Null
    By Wayne311 in forum Programming
    Replies: 4
    Last Post: 01-27-2011, 05:10 PM
  3. Return 0 instead of null
    By salisbut in forum Queries
    Replies: 1
    Last Post: 08-07-2010, 12:01 PM
  4. Query and if null
    By robmict in forum Queries
    Replies: 5
    Last Post: 07-14-2010, 05:04 PM
  5. Replies: 6
    Last Post: 02-19-2010, 03:52 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