J
Jason Kaufman via AccessMonster.com
ok...here is the sql of what i am working on, maybe this will make more sense
to someone out there...
1) First qry gathers data from the Sales Order files in Mas200
SELECT SO2_SOEntryDetailLine.SalesOrderNumber, SO1_SOEntryHeader.
SalesOrderDate, SO1_SOEntryHeader.ShipExpireDate, SO1_SOEntryHeader.Comment,
SO1_SOEntryHeader.CustomerNumber, SO1_SOEntryHeader.CustomerPONumber,
SO2_SOEntryDetailLine.ItemNumber, SO2_SOEntryDetailLine.QtyOrdered,
SO2_SOEntryDetailLine.QtyShipped, SO2_SOEntryDetailLine.QtyBckordr,
SO2_SOEntryDetailLine.UnitPrice, SO2_SOEntryDetailLine.ChrgAmount,
SO2_SOEntryDetailLine.Extension INTO [SO2 Make Table]
FROM SO2_SOEntryDetailLine INNER JOIN SO1_SOEntryHeader ON
SO2_SOEntryDetailLine.SalesOrderNumber = SO1_SOEntryHeader.SalesOrderNumber;
2) Qry 2 filters the data to only look at items with ship due date after
8/1/05
SELECT [SO Make Table].SalesOrderNumber, [SO Make Table].SalesOrderDate, [SO
Make Table].ShipExpireDate, [SO Make Table].Comment, [SO Make Table].
CustomerNumber, [SO Make Table].CustomerPONumber, [SO Make Table].ItemNumber,
[SO Make Table].QtyOrdered, [SO Make Table].QtyShipped, [QtyOrdered]-
[QtyShipped] AS BOQty, [SO Make Table].QtyBckordr, [SO Make Table].UnitPrice,
[SO Make Table].ChrgAmount, [SO Make Table].Extension
FROM [SO Make Table]
WHERE ((([SO Make Table].ShipExpireDate)>#8/1/2005#) AND (([SO Make Table].
ItemNumber) Is Not Null))
ORDER BY [SO Make Table].ShipExpireDate;
3) Qry 3, looks only at all Sales Orders with due date of 11/1/05 or less
SELECT [SO strain].ItemNumber, [SO strain].BOQty, [SO strain].SalesOrderDate,
[SO strain].ShipExpireDate INTO [qry 2 table]
FROM [SO strain]
GROUP BY [SO strain].ItemNumber, [SO strain].BOQty, [SO strain].
SalesOrderDate, [SO strain].ShipExpireDate
HAVING ((([SO strain].ShipExpireDate)<#11/1/2005#))
ORDER BY [SO strain].ItemNumber;
4) This qry, summarizes all the Sales Order quantities that have yet to ship
(with due date of 11/1/05 or less)
SELECT [qry 2 table].ItemNumber, Sum([qry 2 table].BOQty) AS SumOfQtyBO INTO
[qry 3 table]
FROM [qry 2 table]
GROUP BY [qry 2 table].ItemNumber
ORDER BY [qry 2 table].ItemNumber DESC;
5) This qry, takes the results of qry 4 (make table) and takes the SumOfQtyBO
and subtracts it from QtyOnHand to make a new OnHand quantity (this quantity
is based on the theory that everything before the desired date range will
have shipped) and then pushes all the items from previous qry into entire
inventory file, and since qry file is smaller, i had to makes sure a value of
0 was put in instead of null value.
SELECT IM1_InventoryMasterfile.ItemNumber, IM2_InventoryItemWhseDetl.
QtyOnHand, IIf([SumOfQtyBO] Is Null,0,[SumOfQtyBO]) AS BO, [QtyOnHand]-IIf(
[SumOfQtyBO] Is Null,0,[SumOfQtyBO]) AS ReviseOH INTO [qry 4 table]
FROM ([qry 3 table] RIGHT JOIN IM1_InventoryMasterfile ON [qry 3 table].
ItemNumber = IM1_InventoryMasterfile.ItemNumber) INNER JOIN
IM2_InventoryItemWhseDetl ON IM1_InventoryMasterfile.ItemNumber =
IM2_InventoryItemWhseDetl.ItemNumber
WHERE (((IM2_InventoryItemWhseDetl.WhseCode)="000"));
6) This qry draws out the Revised OH qry from previous query within the date
range of 1/1/2005 and 2/1/06 (after I get this mess done, I will be using
'between [start] and [end]'.
SELECT [qry 4 table].ItemNumber, [qry 4 table].ReviseOH, [SO Make Table].
ShipExpireDate INTO [qry 5 table]
FROM [SO Make Table] INNER JOIN [qry 4 table] ON [SO Make Table].ItemNumber =
[qry 4 table].ItemNumber
GROUP BY [qry 4 table].ItemNumber, [qry 4 table].ReviseOH, [SO Make Table].
ShipExpireDate
HAVING ((([SO Make Table].ShipExpireDate) Between #11/1/2005# And #2/1/2006#))
ORDER BY [qry 4 table].ItemNumber DESC;
From here out, I have queries, but ultimately its doesnt get my desired
result.
7)
SELECT [qry 5 table].ItemNumber, [qry 2 table].BOQty INTO [qry 6 table]
FROM [qry 2 table] INNER JOIN [qry 5 table] ON [qry 2 table].ItemNumber =
[qry 5 table].ItemNumber
GROUP BY [qry 5 table].ItemNumber, [qry 2 table].BOQty
ORDER BY [qry 5 table].ItemNumber DESC;
What I want to have happen is to look at the between dates, show the Revised
OH quantity from 5) and then for each item number within a sales order,
subtract the sales order quantity and have a new revised OnHand quantity.
This quantity will then need to be carrried over to the next incident of the
item number and the same process would occur again.
I sort of got this result except for the revised OnHand quantity changing for
each time an item number appeared. I could only get the listing of all the
item numbers with there subsquent sales order quantity and due date but I
could not determine how to link/match them up.
So.
This is my project given to me by my boss in the first week of working here
and now its been 4 weeks since being here and he wants to know if this is
possible. I believe it is, but I just dont know enough to figure it out at
the moment. Apparenlty he had a guy working on a Crystal report for this
same result and he had been working on it for 6 months with no result. I
dont know crystal since where i worked before they didnt know crystal reports
for Mas200 and so used Access instead.
Anyways, if anyone would like to tackle this monster, I would truly be
grateful !!!
Jason
to someone out there...
1) First qry gathers data from the Sales Order files in Mas200
SELECT SO2_SOEntryDetailLine.SalesOrderNumber, SO1_SOEntryHeader.
SalesOrderDate, SO1_SOEntryHeader.ShipExpireDate, SO1_SOEntryHeader.Comment,
SO1_SOEntryHeader.CustomerNumber, SO1_SOEntryHeader.CustomerPONumber,
SO2_SOEntryDetailLine.ItemNumber, SO2_SOEntryDetailLine.QtyOrdered,
SO2_SOEntryDetailLine.QtyShipped, SO2_SOEntryDetailLine.QtyBckordr,
SO2_SOEntryDetailLine.UnitPrice, SO2_SOEntryDetailLine.ChrgAmount,
SO2_SOEntryDetailLine.Extension INTO [SO2 Make Table]
FROM SO2_SOEntryDetailLine INNER JOIN SO1_SOEntryHeader ON
SO2_SOEntryDetailLine.SalesOrderNumber = SO1_SOEntryHeader.SalesOrderNumber;
2) Qry 2 filters the data to only look at items with ship due date after
8/1/05
SELECT [SO Make Table].SalesOrderNumber, [SO Make Table].SalesOrderDate, [SO
Make Table].ShipExpireDate, [SO Make Table].Comment, [SO Make Table].
CustomerNumber, [SO Make Table].CustomerPONumber, [SO Make Table].ItemNumber,
[SO Make Table].QtyOrdered, [SO Make Table].QtyShipped, [QtyOrdered]-
[QtyShipped] AS BOQty, [SO Make Table].QtyBckordr, [SO Make Table].UnitPrice,
[SO Make Table].ChrgAmount, [SO Make Table].Extension
FROM [SO Make Table]
WHERE ((([SO Make Table].ShipExpireDate)>#8/1/2005#) AND (([SO Make Table].
ItemNumber) Is Not Null))
ORDER BY [SO Make Table].ShipExpireDate;
3) Qry 3, looks only at all Sales Orders with due date of 11/1/05 or less
SELECT [SO strain].ItemNumber, [SO strain].BOQty, [SO strain].SalesOrderDate,
[SO strain].ShipExpireDate INTO [qry 2 table]
FROM [SO strain]
GROUP BY [SO strain].ItemNumber, [SO strain].BOQty, [SO strain].
SalesOrderDate, [SO strain].ShipExpireDate
HAVING ((([SO strain].ShipExpireDate)<#11/1/2005#))
ORDER BY [SO strain].ItemNumber;
4) This qry, summarizes all the Sales Order quantities that have yet to ship
(with due date of 11/1/05 or less)
SELECT [qry 2 table].ItemNumber, Sum([qry 2 table].BOQty) AS SumOfQtyBO INTO
[qry 3 table]
FROM [qry 2 table]
GROUP BY [qry 2 table].ItemNumber
ORDER BY [qry 2 table].ItemNumber DESC;
5) This qry, takes the results of qry 4 (make table) and takes the SumOfQtyBO
and subtracts it from QtyOnHand to make a new OnHand quantity (this quantity
is based on the theory that everything before the desired date range will
have shipped) and then pushes all the items from previous qry into entire
inventory file, and since qry file is smaller, i had to makes sure a value of
0 was put in instead of null value.
SELECT IM1_InventoryMasterfile.ItemNumber, IM2_InventoryItemWhseDetl.
QtyOnHand, IIf([SumOfQtyBO] Is Null,0,[SumOfQtyBO]) AS BO, [QtyOnHand]-IIf(
[SumOfQtyBO] Is Null,0,[SumOfQtyBO]) AS ReviseOH INTO [qry 4 table]
FROM ([qry 3 table] RIGHT JOIN IM1_InventoryMasterfile ON [qry 3 table].
ItemNumber = IM1_InventoryMasterfile.ItemNumber) INNER JOIN
IM2_InventoryItemWhseDetl ON IM1_InventoryMasterfile.ItemNumber =
IM2_InventoryItemWhseDetl.ItemNumber
WHERE (((IM2_InventoryItemWhseDetl.WhseCode)="000"));
6) This qry draws out the Revised OH qry from previous query within the date
range of 1/1/2005 and 2/1/06 (after I get this mess done, I will be using
'between [start] and [end]'.
SELECT [qry 4 table].ItemNumber, [qry 4 table].ReviseOH, [SO Make Table].
ShipExpireDate INTO [qry 5 table]
FROM [SO Make Table] INNER JOIN [qry 4 table] ON [SO Make Table].ItemNumber =
[qry 4 table].ItemNumber
GROUP BY [qry 4 table].ItemNumber, [qry 4 table].ReviseOH, [SO Make Table].
ShipExpireDate
HAVING ((([SO Make Table].ShipExpireDate) Between #11/1/2005# And #2/1/2006#))
ORDER BY [qry 4 table].ItemNumber DESC;
From here out, I have queries, but ultimately its doesnt get my desired
result.
7)
SELECT [qry 5 table].ItemNumber, [qry 2 table].BOQty INTO [qry 6 table]
FROM [qry 2 table] INNER JOIN [qry 5 table] ON [qry 2 table].ItemNumber =
[qry 5 table].ItemNumber
GROUP BY [qry 5 table].ItemNumber, [qry 2 table].BOQty
ORDER BY [qry 5 table].ItemNumber DESC;
What I want to have happen is to look at the between dates, show the Revised
OH quantity from 5) and then for each item number within a sales order,
subtract the sales order quantity and have a new revised OnHand quantity.
This quantity will then need to be carrried over to the next incident of the
item number and the same process would occur again.
I sort of got this result except for the revised OnHand quantity changing for
each time an item number appeared. I could only get the listing of all the
item numbers with there subsquent sales order quantity and due date but I
could not determine how to link/match them up.
So.
This is my project given to me by my boss in the first week of working here
and now its been 4 weeks since being here and he wants to know if this is
possible. I believe it is, but I just dont know enough to figure it out at
the moment. Apparenlty he had a guy working on a Crystal report for this
same result and he had been working on it for 6 months with no result. I
dont know crystal since where i worked before they didnt know crystal reports
for Mas200 and so used Access instead.
Anyways, if anyone would like to tackle this monster, I would truly be
grateful !!!
Jason