Results 1 to 6 of 6
  1. #1
    sgp667 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2012
    Posts
    17

    Querry not matching records

    So I have two(relevant) tables one that lists products bought and another that lists inventory level in storage. I wrote a query that calculates average rate that we use inventory at, and another that states most recent inventory level. Now to make that information useful I need to combine it together.


    I need to estimate today's inventory level I am rather certain that formula for that should be:

    (Most recent inventory level) - (days since inventory was measured) * ( average usage rate) = Estimates inventory level


    The problem is that when I try to include records from both queries( one that states most recent counted inventory, and one that calculates depletion rate) the final query instead of matching items applies each record form the queries to each record from the other query, I'll illustrate:

    My notation "Level" - recent Inventory level, "usage" - average usage, A B C - different items

    What I want

    Level of A Usage of A
    Level of B Usage of B
    Level of C Usage of C

    What I get

    Level of A Usage of A
    Level of A Usage of B
    Level of A Usage of C
    Level of B Usage of A
    Level of B Usage of B
    Level of B Usage of C
    Level of C Usage of A
    Level of C Usage of B
    Level of C Usage of C

    I will upload the access file late I just need more time before I reduce size of it to fit upload requirements.

    Thanks!

  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,930
    Show the SQL statement of the query. Sounds like it does not have a JOIN clause.
    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
    sgp667 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2012
    Posts
    17
    To be honest with you I know very little about SQL most of the time I let Access compile it for me, that includes this case:
    SELECT [Most Recent Inventory Update].Item, [Most Recent Inventory Update].Count, [Depletion Rate].Usage, [Most Recent Inventory Update]!Count-DateDiff("d",[Most Recent Inventory Update]!["Date"],Date())*[Depletion Rate]!Usage AS [Estimated Inventory]
    FROM [Most Recent Inventory Update], [Depletion Rate];

    Indeed the JOIN clause is missing. However I am not that sure how to incorporate JOIN into this my guess would be that I have to state that [Most Recent Inventory Update].Item is the same as [Depletion Rate].Item

  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,930
    Select the linking field in one table and drag to the linking field in other table. Click on the resulting line to edit the join type.

    Access will create the query join only if Relationships are established.
    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
    sgp667 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2012
    Posts
    17
    Ok so I joined the fields together like you suggested but new problem came up.
    The fields imported from Joined table show up as empty.

    Here is the SQL I used, I have tried this with different fields of "right"(joined) table but all show up as blank.

    SELECT [Most Recent Inventory Update].Item, Max([Most Recent Inventory Update].Date) AS Checked, [Depletion Rate].Usage
    FROM [Most Recent Inventory Update] LEFT JOIN [Depletion Rate] ON [Most Recent Inventory Update].Item = [Depletion Rate].Item
    GROUP BY [Most Recent Inventory Update].Item, [Depletion Rate].Usage;

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Need to know more about data structure. Post sample data or provide database. Follow instructions at bottom of my post.
    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.

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

Similar Threads

  1. Replies: 2
    Last Post: 04-27-2012, 05:27 PM
  2. Query to exclude non matching records
    By L1882 in forum Queries
    Replies: 1
    Last Post: 04-03-2012, 08:44 AM
  3. Replies: 1
    Last Post: 10-24-2011, 08:01 AM
  4. Replies: 1
    Last Post: 08-11-2011, 11:33 AM
  5. Replies: 9
    Last Post: 06-23-2010, 02:06 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