Hi Duane,
I'm not Art, I'm Doyce but your description is correct. Here is some sample data:
MAXID | PartID | TDate | COST_01 | TNXQTY_15 | RunTotal | onhand_01 | D | LeftSum | AgeQty |
---|---|---|---|---|---|---|---|---|---|
2792852 | 1001004 | 9/28/2016 | 12.6 | 1 | 1 | 3 | -1 | 0 | 1 |
2248382 | 1001004 | 7/23/2014 | 12.6 | 3 | 5 | 3 | -1 | -1 | 1 |
2248716 | 1001004 | 7/23/2014 | 12.6 | 1 | 2 | 3 | -1 | -2 | 1 |
2248386 | 1001011 | 7/23/2014 | 2.7 | 8 | 9 | 7 | -1 | -6 | 6 |
2248723 | 1001011 | 7/23/2014 | 2.7 | 1 | 1 | 7 | -1 | 0 | 1 |
2248387 | 1001012 | 7/23/2014 | 2.7 | 8 | 9 | 7 | -1 | -6 | 6 |
2248724 | 1001012 | 7/23/2014 | 2.7 | 1 | 1 | 7 | -1 | 0 | 1 |
2785852 | 1001017 | 9/13/2016 | 10.8 | 2 | 2 | 1 | -1 | 0 | 0 |
2785854 | 1001020 | 9/13/2016 | 24.05 | 2 | 2 | 1 | -1 | 0 | 0 |
2785909 | 1001022 | 9/13/2016 | 2.25 | 4 | 4 | 2 | -1 | 0 | 0 |
2785910 | 1001024 | 9/13/2016 | 1.5 | 2 | 2 | 1 | -1 | 0 | 0 |
I have already created a report based on this query that puts the amounts in the correct aging buckets. If you notice in the data above, the parts that have more than one receipt, the AgeQty and LeftSum calculations are correct. However, if a part has only been received one time, the LeftSum and AgeQty calculations return zero. This is because of the NZ function in the formula. If I remove that from the formula, the calculation returns a null. I'm thinking there is a better way to calculate the LeftSum. If I can get that fixed, I think the AgeQty will calculate correctly. Here is the SQL for the query:
SELECT [Transaction History].MAXID, [Transaction History].PRTNUM_15 AS PartID, [Transaction History].TNXDTE_15 AS TDate, [Part Master].COST_01, [Transaction History].TNXQTY_15, DSum("tnxqty_15","Transaction History","PrtNum_15='" & [PartID] & "'and TNXCDE_15 = '" & "R" & "' and MAXID >= '" & [MAXID] & "'") AS RunTotal, [Part Master].onhand_01, IIf(Nz((Nz((DSum("tnxqty_15","Transaction History","PrtNum_15='" & [PartID] & "' and TNXCDE_15 = '" & "R" & "' and MAXID > '" & [MaxID] & "'")-[onhand_01]),0)),0)<=0,True,False) AS D, Nz((DSum("tnxqty_15","Transaction History","PrtNum_15='" & [PartID] & "' and TNXCDE_15 = '" & "R" & "' and MAXID > '" & [MAXID] & "'")-[onhand_01]),0) AS LeftSum, IIf([RunTotal]<[Onhand_01],[TNXQTY_15],Abs((Nz((DSum("tnxqty_15","Transaction History","PrtNum_15='" & [PartID] & "' and TNXCDE_15 = '" & "R" & "' and MAXID > '" & [MaxID] & "'")-[onhand_01]),0)))) AS AgeQty
FROM [Part Master] INNER JOIN [Transaction History] ON [Part Master].PRTNUM_01 = [Transaction History].PRTNUM_15
WHERE ((([Transaction History].TNXCDE_15)="R") AND (([Part Master].onhand_01)>0))
ORDER BY [Transaction History].PRTNUM_15, [Transaction History].TNXDTE_15 DESC;
---In MS_Access_Professionals@yahoogroups.com, <duanehookom@...> wrote :
Sent: Monday, September 9, 2019 4:36 PM
To: MS_Access_Professionals@yahoogroups.com <MS_Access_Professionals@yahoogroups.com>
Subject: RE: [MS_AccessPros] Inventory Aging
---In MS_Access_Professionals@yahoogroups.com, <r.koelmans@...> wrote :
Posted by: winberry.doyce@con-way.com
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (7) |
Tidak ada komentar:
Posting Komentar