Results 1 to 13 of 13
  1. #1
    smeghead67 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    31

    Nz function question

    Hello,



    I have a select query where I'm trying to get it to return a 0 if the sum is null

    Code:
    SELECT DISTINCTROW Sum(Nz([partstore Query].qty, 0)) AS Inventory
    FROM [partstore Query]
    WHERE ((([partstore Query].[partstore].[binid]) Like "I*"));
    when I run it i get no value in the result.

    Smeghead67

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    The text in RED shouldn't be there.
    Code:
    SELECT DISTINCTROW Sum(Nz([partstore Query].qty, 0)) AS Inventory 
    FROM [partstore Query] 
    WHERE ((([partstore Query].[partstore].[binid]) Like "I*"));
    Also, is binid a text field???

    Are records returned if you execute this query?
    Code:
    SELECT DISTINCTROW Nz([partstore Query].qty, 0) AS Inventory 
    FROM [partstore Query] 
    WHERE ((([partstore Query].[binid]) Like "I*"));

  3. #3
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    I am having a difficult time understanding your Where clause. You have referenced a field (partstore) in the query (partstore Query) but what is binid? Is it another field in the partstore query?

    Alan

    Edit: Steve types faster. Same issues.

  4. #4
    smeghead67 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    31
    ssanfu,

    well I removed the extra text and it did not make a diffrence.

    The second code did not work either

  5. #5
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Please explain what you are specifically trying to do. Perhaps, if we understand your intentions, then a good solution will result.

  6. #6
    smeghead67 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    31
    alansidman,

    the text in red was not supposed to be there. binid is a text field in the partstore query. i have 6 seprate storage areas where parts could be in bins. I decided to give each room a identifying letter to start it. eg L01-01-01 is at the lodge storage area rack 1, shelf 1 down from the top and bin 1 from the left. i could have the same part in more than one bin in one area. when the partstore query is ran, it selects all parts from that table filtered by the part id. then i use this query to give me a quick total of how many parts i have in a specific storage area.

    Ted

  7. #7
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    What are hoping to achieve using the DistinctRow SQL function. What happens when you run it as a select query without the DistinctRow? Without seeing your db, it is a case of guessing. If you want to upload a copy (sanitized for confidential material) it would help. Make sure to run a compact and repair and if possible save as an AC2003 version (.mdb) to allow maximum viewership.

  8. #8
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    First thing is to get the [partstore Query] to return records.

    Then check for records using:
    Code:
    SELECT [partstore Query].qty, AS Inventory  
    FROM [partstore Query]  
    WHERE ((([partstore Query].[binid]) Like "I*"));
    After that, try:
    Code:
    SELECT Nz([partstore Query].qty, 0) AS Inventory  
    FROM [partstore Query]  
    WHERE ((([partstore Query].[binid]) Like "I*"));

    Alan: I really type slower... I just have to start sooner......

  9. #9
    smeghead67 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    31
    Alan,

    I removed distintrow and it still works. the query wizard put it in there.

    I clicked compact database, now it will not let me save a copy of the database. umm, if that screwed it up, im not going to be happy. i have let it sit for 20 minutes now. there is no real data in the database just 2 make believe parts i made to test my concept.

    Ted

  10. #10
    smeghead67 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    31
    Steve,

    in your first query the comma caused an error I fixed that and it gave me the usual no value.

    The second one gave me a table but it had the asterisk to the left as if it was going to start data into a new table.

  11. #11
    smeghead67 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    31
    I tried it in both 03 and 07 formats and it is too big. 545kb and 640kb respectively. i dont know how to get it any smaller.

  12. #12
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Now zip the db and it will post.

  13. #13
    smeghead67 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    31
    Ok,

    Here it is. I also sent this to the forms area. being a noob means listening to you guy's good advice.

    Slot.zip

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

Similar Threads

  1. query function question
    By Daryl2106 in forum Access
    Replies: 1
    Last Post: 02-29-2012, 10:40 PM
  2. function question
    By manic in forum Programming
    Replies: 4
    Last Post: 02-10-2012, 04:14 PM
  3. Question; Count function ..
    By efleming in forum Queries
    Replies: 4
    Last Post: 05-27-2011, 08:05 AM
  4. Want function to get current function name
    By Davis DeBard in forum Programming
    Replies: 2
    Last Post: 08-13-2009, 05:02 AM
  5. function key
    By marianne in forum Access
    Replies: 5
    Last Post: 05-14-2009, 01:26 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