+ Reply to Thread
Results 1 to 3 of 3

Thread: Total stock calculation query

  1. #1
    Registered User
    Join Date
    12-02-2009
    Location
    Birmingham, UK
    MS-Off Ver
    2000 & 2007
    Posts
    82

    Total stock calculation query

    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.

    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))
    tbl Transaction:
    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...

  2. #2
    Extremely Helpful member
    Join Date
    12-23-2006
    Location
    Belgium
    MS-Off Ver
    XL2003
    Posts
    6,127

    Re: Total stock calculation query

    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

  3. #3
    Valued Forum Contributor
    Join Date
    04-23-2009
    Location
    IOWA
    MS-Off Ver
    2010 Professional
    Posts
    270

    Re: Total stock calculation query

    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!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0