Selasa, 10 September 2019

Re: [MS_AccessPros] Inventory Aging

 

Doyce,

Sorry about messing up your name. I need more coffee.

I would try move the Nz() to address only the DSum()

Nz(DSum("tnxqty_15","Transaction History","PrtNum_15='" & [PartID] & "' and TNXCDE_15 = 'R' and  MAXID > '" & [MAXID] & "'"),0)-[onhand_01] AS LeftSum

Duane


From: MS_Access_Professionals@yahoogroups.com <MS_Access_Professionals@yahoogroups.com> on behalf of winberry.doyce@con-way.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com>
Sent: Tuesday, September 10, 2019 9:13 AM
To: MS_Access_Professionals@yahoogroups.com <MS_Access_Professionals@yahoogroups.com>
Subject: Re: [MS_AccessPros] Inventory Aging
 


Hi Duane,


I'm not Art, I'm Doyce but your description is correct. Here is some sample data:


qryInvAgingSelect
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;
 

Doyce

---In MS_Access_Professionals@yahoogroups.com, <duanehookom@...> wrote :

Hi Art,

I believe you want to start with the number on hand (current inventory) and step backwards chronologically to see when you can account for purchasing a specific quantity and the price paid. The purchase date will identify the bucket the quantity and price go into. When all of the number on hand have been accounted for you are done putting prices and quantities into buckets.

Do you have some sample records and how you would want these reported?

Thanks,
Duane 
From: MS_Access_Professionals@yahoogroups.com <MS_Access_Professionals@yahoogroups.com> on behalf of winberry.doyce@... [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com>
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
 


Hi Rob,


No, that's not quite it. I need to know how long my inventory has been here.. If I have a part with more than one receipt, I need it divided by receipt date. Example part A has 50 on hand. I received 20 in May and 10 in July and 20 in August. I need to know that if Part A cost $1 that I have $20 of current inventory, $10 of 60 day inventory and $20 of 90 day inventory.


Thanks for taking time to answer.


Doyce



---In MS_Access_Professionals@yahoogroups.com, <r.koelmans@...> wrote :

Hi Doyce,

If I understand right, your issue is whether what you still have on stock was purchased for the last time.

So you need a query that gives the last receiving date of items with OnHand_01 <> 0. That's a simple join on the two tables.

Next you use that query in a query that groups on month of the last purchased date. Unless I misunderstand what info is needed, that would do the job I think.

Rob

 

From: MS_Access_Professionals@yahoogroups.com <MS_Access_Professionals@yahoogroups.com>
Sent: donderdag 5 september 2019 06:08
To: MS_Access_Professionals@yahoogroups.com
Subject: Re: [MS_AccessPros] Inventory Aging

 

 

A couple suggestions:

Every time I read about a specification for "buckets" I create a table of "buckets" with MinBucketValue, MaxBucketValue, and BucketTitle. 

 

Is MAXID numeric? You are using a numeric operator ">=" and yet comparing it with a string.

 

You are calculating LeftSum in the query and also using LeftSum in other expression. I never do this. I would repeat the LeftSum expression/calculation in place of using LeftSum elsewhere.

 

You do the same thing with SeqID. Why not use [Transaction History].MAXID?

 

I would always make sure there is a space prior to the "and". You have ..."'and TNXCDE_15....

 

This might or might not resolve your issue but I would sleep better.

 

Duane

 

From: MS_Access_Professionals@yahoogroups.com <MS_Access_Professionals@yahoogroups.com> on behalf of winberry.doyce@... [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com>
Sent: Wednesday, September 4, 2019 2:54 PM
To: MS_Access_Professionals@yahoogroups.com <MS_Access_Professionals@yahoogroups.com>
Subject: [MS_AccessPros] Inventory Aging

 




Hello Pros,

I have been ask to come up with a way to "age" our inventory into buckets based on receipt date using FIFO. "Current" inventory has been received in the last 29 days. Inventory received between 30 and 59 days ago would go into the "30 day" bucket and etc. I have approached doing this by going through the receipt transactions in our Transaction History table in descending date order and comparing the transaction Qty to the onhand qty. The following SQL is almost getting me what I want. It works fine as long as there are more than 1 receipt for a part. If it is a part that has been purchased and received only once, the AgeQty calculation fails and returns 0. Here are the fields in the query and a brief description of each:

SeqID is an alias for MaxID which is the primary key in the transaction history table. It is autonumber.

TDate - Transaction Date (Receipt Date)

TNXCDE_15 - Transaction Code. "R" is an inventory receipt

Cost_01 -  The cost of the part. Used to value the inventory.

TNXQTY_15 - The quantity of the part being received.

RunTotal - The sum of the parts received starting with the most recent receipt in descending date order

Onhand_01 - The total number of parts we currently have onhand

D - a Boolean as to whether this receipt should be included in the aging.

LeftSum - How many are left to allocate

AgeQty - how many are in this age bucket.

Part Master is the table with the parts records

Transaction History is the table with the receipt records.

 

Here is the SQL for the query:

SELECT [Transaction History].MAXID AS SeqID, [Transaction History].PRTNUM_15 AS PartID, [Part Master].PMDES1_01, [Transaction History].TNXDTE_15 AS TDate, [Transaction History].TNXCDE_15, [Part Master].COST_01, [Transaction History].TNXQTY_15, DSum("tnxqty_15","Transaction History","PrtNum_15='" & [PartID] & "'and TNXCDE_15 = '" & "R" & "' and MAXID >= '" & [SeqID] & "'") AS RunTotal, [Part Master].onhand_01, IIf(Nz([leftSum],0)<=0,True,False) AS D, Nz((DSum("tnxqty_15","Transaction History","PrtNum_15='" & [PartID] & "'and TNXCDE_15 = '" & "R" & "' and  MAXID > '" & [SeqID] & "'")-[onhand_01]),0) AS LeftSum, IIf([RunTotal]<[Onhand_01],[TNXQTY_15],Abs([Leftsum])) AS AgeQty
FROM [Part Master] INNER JOIN [Transaction History] ON [Part Master].PRTNUM_01 = [Transaction History].PRTNUM_15
WHERE ((([Transaction History].TNXCDE_15)="R"))
ORDER BY [Transaction History].PRTNUM_15, [Transaction History].TNXDTE_15 DESC;

 

The query results all look good except for the LeftSum calculation and the AgeQty calculation and they are correct for all parts that have more than one receipt. If a part has only been received once, the calculations show zero.

How can I get this query to correctly age all receipts? Is this the best approach to my request? I adapted this approach from this post I found on Experts Exchange. https://www.experts-exchange.com/questions/27920676/Inventory-Aging.html

 

Doyce

 

 





__._,_.___

Posted by: Duane Hookom <duanehookom@hotmail.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (8)

.

__,_._,___

Tidak ada komentar:

Posting Komentar