Results 1 to 5 of 5
  1. #1
    pj2024 is offline Novice
    Windows 11 Office 365
    Join Date
    Aug 2024
    Posts
    2

    Need help on Allocations (similar to FIFO/LIFO?) using 2 tables

    Hi everyone,

    My example is I have 2 tables and need the 3rd table as my output. The goal is to deduct all I can from Bank A, then B and finally C based on numbers from table 2. Table 1 and 2 will always be the same amount.

    i tried to use the example here but doesnt seem to work if i change the numbers (https://stackoverflow.com/questions/...s-in-ms-access)

    Greatly appreciate any help !



  2. #2
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Best that you post what you tried, else how are we supposed to see what's wrong with that?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    pj,

    Have you searched this forum for FIFO? I know there have been sample databases and discussions over the last few years.

  4. #4
    pj2024 is offline Novice
    Windows 11 Office 365
    Join Date
    Aug 2024
    Posts
    2
    sure...If I use 25 (or higher) the query seems to work. If you choose 9 (as an example) - i get some negative numbers in the output

  5. #5
    ano is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Nov 2023
    Posts
    204
    the parameter is for testing without form, if order is from table u need to join the table
    Code:
    PARAMETERS [order] Long;SELECT Product.Prod, Product.Btch, Product.Qty, (Select Sum(Qty) 
    From Product As T 
    Where T.Prod = Product.Prod And 
                T.Btch <= Product.Btch) AS Total,
     IIf([Total] - [Order]<=0, [Qty],
     iif([Order]-([Total]-[Qty])<=0,0,[Order]-([Total]-[Qty]))) AS Sale
    FROM Product;
    add iif for no wrong result

    to insert into 3rd table use nxt code
    Code:
    INSERT INTO sale ( prd, btch, sle )SELECT p.[prod], p.btch, p.sale
    FROM [product query] AS p
    WHERE p.sale > 0;
    Last edited by ano; 08-30-2024 at 10:00 PM.

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

Similar Threads

  1. Query question Dates and Allocations
    By axg275 in forum Access
    Replies: 14
    Last Post: 01-31-2023, 03:38 AM
  2. One or two tables of similar data
    By Ant_Snell in forum Database Design
    Replies: 2
    Last Post: 02-15-2022, 07:12 AM
  3. FIFO & LIFO inventory system
    By Hareshvalani in forum Access
    Replies: 5
    Last Post: 02-04-2021, 06:33 AM
  4. Need to Merge 6 Similar Tables
    By CJS in forum Queries
    Replies: 6
    Last Post: 04-21-2015, 10:14 AM
  5. Implementing LiFo Stack, an implementation
    By GraeagleBill in forum Code Repository
    Replies: 2
    Last Post: 06-08-2014, 03:24 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