Add a third field to your InvTransType table
Name that field IT_CATEGORY
Put a C in the STOCK record
Put a D in the SELL record
(c for credit d for debit)
Run this query:
Code:
SELECT InvTrans.WID, InvTrans.PID, Sum(IIf([it_category]="C",[qty],0)) AS Receipt, Sum(IIf([it_category]="D",[qty],0)) AS Disbursement, Sum(IIf([it_category]="C",[qty],0)-IIf([it_category]="D",[qty],0)) AS OnHandFROM InvTransType RIGHT JOIN InvTrans ON InvTransType.ITTID = InvTrans.ITType
WHERE (((InvTrans.ITDate) Between [enter start date] And [enter end date]))
GROUP BY InvTrans.WID, InvTrans.PID;
Modifying your InvTransType table this way will also allow you to track internal transfers (transfer in/transfer out) and allocate the positives and negatives correctly