Results 1 to 6 of 6
  1. #1
    jonny3000 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2012
    Posts
    7

    Using the Nz function (Access 07)

    I have tried using the Nz function to return the value of '0' but still get null everytime and can't seem to get the syntax right. I also tried to use a IIf statement asking if null then show awaiting count, else show account count - depart count. What Im trying to over all is show the total of awaiting and as someone departed it will deduct from the awaiting total. I started biulduing the query in the form to solve for the counts but after realizing that if the depart value is null then the awaiting value would then be null too. I need the awaiting value to show its true value and then as they depart the awaiting value would be subtracted. Here is a couple of SQL I have tried so far.

    SELECT Nz(([Awaiting Count].[CountOfBN]-[Departed Count].[CountOfBN]),0) AS Awaiting


    FROM [Departed Count], [Awaiting Count];


    SELECT IIf([Departed Count].[CountOfBN] Is Null,[Awaiting Count].[CountOfBN],[Awaiting Count].[CountOfBN]-[Departed Count].[CountOfBN]) AS Awaiting
    FROM [Departed Count], [Awaiting Count];

    I have tried other syntax but can't seem to nail it. I tried using the Nz function before and never had any success. Any help would be greatly appreciated.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    Why isn't there a JOIN clause in that query to join the two tables on common unique ID?

    The Nz() expression has unnecessary pair of parens but should still work with tables properly joined.
    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
    jonny3000 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2012
    Posts
    7
    I can't join the two querys. I am trying to count the amount of awaiting and departed and did so in a seperate query. I know I can do within the form but just trying different methods to try and get the Nz function to work.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    If you don't define a join on common ID fields, then every record in each table will join to every record in the other table.

    I don't understand what you are trying to do.
    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.

  5. #5
    DatabaseMakers is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2012
    Location
    London
    Posts
    12
    what about:

    SELECT (Nz([Awaiting Count].[CountOfBN],0)-Nz([Departed Count].[CountOfBN],0)) AS Awaiting
    FROM [Departed Count], [Awaiting Count];

  6. #6
    dreday's Avatar
    dreday is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    58
    Quote Originally Posted by June7 View Post
    If you don't define a join on common ID fields, then every record in each table will join to every record in the other table.

    I don't understand what you are trying to do.
    This is correct, what you have is won't generate anything useful from a cross join.

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

Similar Threads

  1. Access - Eval function
    By dodo47 in forum Access
    Replies: 19
    Last Post: 02-11-2012, 02:02 AM
  2. function in access
    By ali zaib in forum Access
    Replies: 3
    Last Post: 01-14-2012, 01:09 PM
  3. NZ Function in Access Query
    By Rosier75 in forum Queries
    Replies: 2
    Last Post: 11-02-2011, 06:14 AM
  4. Help with Access - IIf Function
    By cs93 in forum Programming
    Replies: 7
    Last Post: 03-19-2011, 11:52 AM
  5. excel function in access
    By lmp101010 in forum Queries
    Replies: 1
    Last Post: 08-03-2010, 05:02 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