Hello,
I was trying to set-up a query that will ask for a part number from tblPartNumber and sum the stock for this part according to transaction type in tblTransactions.
This is the code I use for suming it.
tbl Transaction:TotalStock: Sum(IIf([TranType]="Arrival",[Qty],0)+IIf([TranType]="InvIn",[Qty],0)+IIf([TranType]="CountIn",[Qty],0)-IIf([TranType]="InvOut",[Qty],0)-IIf([TranType]="CountOut",[Qty],0)-IIf([TranType]="Despatch",[Qty],0))
PartNumber; Qty; TranType;
Do you know of a top of your heads if there is any basic mistake in a code?
If anyone has any idea please let me know.
Thanks for reading this
Simon
Life is brutal and full of ambushes and sometimes is kicking as...
Not quite sure, but is the SUM function necessary ?
You are adding/substracting a number of IIf conditions, the SUM seems redundant
Quoting entire posts clutters the forum and makes threads hard to read !
If you are pleased with a member's answer then use the Star icon to rate it
Click here to see forum rules
Simon,
Download the Northwind Database, there are plenty of examples there for inventory. It is free from Microsoft. If you have questions after looking at that let me know.
Inventory can be an ugly thing. If you have multiple parts that make up one assembly and possibly have multiple parts that make up a part listed in an assembly you end up having to write recursive code. (Fun to learn though imo)
Hope the Northwind DB helps you,
Dan
"I am not a rocket scientist, I am a nuclear engineer." - Split_atom18
If my advice has been helpful to you, then please help me by clicking on the "Star" and adding to my reputation, Thanks!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks