Results 1 to 6 of 6
  1. #1
    Myint Aye is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Dec 2018
    Posts
    3

    show zero value in query for all no data field in joined table

    Hi All :
    Greeting from New Form member.
    I would like to get suggestion or help in forming query.
    I have made 2 tables employee data and leave record.I made query for all employees and their leave taken. In leave record table, some employee took leave and some din not take leave . Leave record shows only employees who took leave, I made outer join in employee register number joining type is 2 Include ALL records from 'employee data' and only those records from 'leave record' where the joined fields are equal.The query shows all employee register number but leave day shows empty for all employees .
    I would like to show all employees who took leave days and zero who did not take leave .
    Could you pls give example conditional expression for required field.



    Thanks for all
    Myint Aye

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Try Nz() function: Nz([fieldname],0)

    Review http://allenbrowne.com/QueryPerfIssue.html#Nz
    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
    Myint Aye is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Dec 2018
    Posts
    3
    Quote Originally Posted by June7 View Post
    Try Nz() function: Nz([fieldname],0)

    Review http://allenbrowne.com/QueryPerfIssue.html#Nz
    Hi:
    I make the following.
    SELECT EMPLOYEE.[EMPLOYEE NO], IIf([Query2].[SumOfPERIOD] Is Null,0,[Query2].[SumOfPERIOD]) AS Expr1
    FROM EMPLOYEE LEFT JOIN Query2 ON EMPLOYEE.[EMPLOYEE NO] = Query2.[EMPLOYEE NO];
    all record from Exper1 field from new query show zero value although there are somerecord in [Query2].[SomOfPERIOD] have numeric values.
    could you pls correct it.
    T&R
    Myint Aye

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    Here is a mockup using my tables.
    Click image for larger version. 

Name:	StartingTables.PNG 
Views:	14 
Size:	32.4 KB 
ID:	36599



    Code:
    SELECT tblGEmployee.EmpID
    , Iif ( IsNull(Sum(EmpLeave.[LeaveTakenDays])),0,Sum(EmpLeave.[LeaveTakenDays]) ) as TotalTaken
    FROM  tblGEmployee Left JOIN EmpLeave 
    ON EmpLeave.EmpID = tblGEmployee.EmpID
    GROUP BY tblGEmployee.EmpID;
    Click image for larger version. 

Name:	ResultOfQuery.PNG 
Views:	14 
Size:	7.4 KB 
ID:	36600
    Good luck with your project.

  5. #5
    Myint Aye is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Dec 2018
    Posts
    3
    Hi Orange.
    Thank you for your reply . That is the point I need . I have assigned employee no as short text and When I make query that is OK .But when I join table with query to produce report ,It still show zero value . I suspect my query and when I change query as table , The employee no shows ID number (not employee no)and the system cannot get matched join field with employee.employee no then it show zero value . I have made new file in which employee no is number format. Then it works properly . I would like to say thanks again for your help.

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722

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

Similar Threads

  1. Replies: 1
    Last Post: 05-06-2015, 04:28 AM
  2. Replies: 7
    Last Post: 02-03-2012, 04:41 PM
  3. Lookup name in a query on a non-joined table
    By karmacable in forum Queries
    Replies: 7
    Last Post: 09-21-2011, 09:01 AM
  4. Replies: 0
    Last Post: 06-15-2011, 07:02 AM
  5. Data won't show up in table field
    By texzen123 in forum Forms
    Replies: 3
    Last Post: 11-26-2009, 11:20 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