Results 1 to 7 of 7
  1. #1
    nightangel73 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    May 2014
    Posts
    45

    Still can't get quantiy on hand for all records

    Okay I have this tables that look like this



    Lots
    Lot Number
    QuantityIN

    Retain Orders
    OrderID
    Requested by

    OrderIDDetails
    Lot Number
    RequestID
    Quantity Withdrawn
    Quanity Returned

    So I build a query that gives me quantity on hand for all the lots where there was an order of withdrawn. But if there is no orders then quantity on hand is blank in the query because there is no records. Now I would like the query to show me that the quantity on hand for the lots with no orders to be the Quantity in.

    Is this possible to do in a simple way? Help appreciated.

  2. #2
    lfpm062010 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    If you use the an outter join (left or right join), it will give you an NULL for the field that does not have matching key value.

  3. #3
    nightangel73 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    May 2014
    Posts
    45
    Quote Originally Posted by lfpm062010 View Post
    If you use the an outer join (left or right join), it will give you an NULL for the field that does not have matching key value.
    I don't know how to do this.

  4. #4
    lfpm062010 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    For example, if you left join Table "Lots" and Table "OrderIDDetails". If there is Lot Number that is not in table "OrderIDDetails", then the NULL will be filled in for those fields in "OrderIDDetails".

    SELECT Lots.[Lot Number], Lots.QuantityIN, OrderIDDetails.[Quantity Withdrawn], OrderIDDetails.[Quanity Returned]
    FROM Lots LEFT JOIN OrderIDDetails ON Lots.[Lot Number] = OrderIDDetails.[Lot Number];

  5. #5
    nightangel73 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    May 2014
    Posts
    45
    I tried editing the join type with all possible ways and it will not give me the null values. If no withdrawn it still blank fields.

  6. #6
    nightangel73 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    May 2014
    Posts
    45
    Quote Originally Posted by nightangel73 View Post
    I tried editing the join type with all possible ways and it will not give me the null values. If no withdrawn it still blank fields.
    The left join is pulling the records correctly it just not putting the null value. Why is this?

  7. #7
    lfpm062010 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    The null value will only show if table "OrderIDDetails" does not have the lot number.

    For example:
    LOTS:
    Lot Number-----QuantityIN
    =======-----=======
    1234 100
    5678 200
    9012 10

    OrderIDDetails
    Lot Number---RequestID---Quantity Withdrawn---Quanity Returned
    =======---=======---============---===========
    1234 1 50 25
    4567 2 20 10

    In the above case, the Lot Number 9012 does not have matching key in Table "OrderIDDetails". Then the NULL value will be filled in for RequestID, Quantity Withdrawn, and Quanity Returned.

    If you still have problem, can you post your sample data and your SQL. If possible, post your sample Access database will be even better.

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

Similar Threads

  1. Calculate available Assets at hand
    By AIMIS in forum Queries
    Replies: 1
    Last Post: 08-07-2013, 09:06 AM
  2. How to calculate current balance on hand
    By fazly lee in forum Access
    Replies: 11
    Last Post: 09-05-2012, 09:16 PM
  3. calculating On Hand Quantity
    By hbm001 in forum Queries
    Replies: 18
    Last Post: 04-24-2012, 09:42 AM
  4. free hand drawing in access? is it possible
    By MyWebdots in forum Access
    Replies: 1
    Last Post: 07-15-2011, 10:39 AM
  5. Total noob needs a helping hand?
    By Naz in forum Access
    Replies: 7
    Last Post: 01-28-2010, 08:35 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